Request: free monad

Flow-static-land has an implementation of the Free monad.
Is it possible to include it in this library too?

A first attempt
// adapted from http://okmij.org/ftp/Computation/free-monad.html

import { HKT, HKTS } from 'fp-ts/lib/HKT'
import { FantasyMonad, StaticMonad } from 'fp-ts/lib/Monad'

export type NaturalTransformation<F extends HKTS, G extends HKTS> = <A>(fa: HKT<A>[F]) => HKT<A>[G]

declare module 'fp-ts/lib/HKT' {
  interface HKT<A> {
    Free: Free<any, A>
  }
}

export const URI = 'Free'

export type URI = typeof URI

export type Free<F extends HKTS, A> = Pure<F, A> | Impure<F, A, any>

export class Pure<F extends HKTS, A> implements FantasyMonad<URI, A> {
  static of = of
  readonly _tag: 'Pure'
  readonly _F: F
  readonly _A: A
  readonly _URI: URI
  constructor(public readonly a: A) {}
  map<B>(f: (a: A) => B): Free<F, B> {
    return new Pure<F, B>(f(this.a))
  }
  of<B>(b: B): Free<F, B> {
    return of<F, B>(b)
  }
  ap<B>(fab: Free<F, (a: A) => B>): Free<F, B> {
    return fab.chain(f => this.map(f)) // <- derived
  }
  chain<B>(f: (a: A) => Free<F, B>): Free<F, B> {
    return f(this.a)
  }
  foldMap<M extends HKTS>(monad: StaticMonad<M>, f: NaturalTransformation<F, M>): HKT<A>[M] {
    return monad.of(this.a)
  }
}

export class Impure<F extends HKTS, A, X> implements FantasyMonad<URI, A> {
  static of = of
  readonly _tag: 'Impure'
  readonly _F: F
  readonly _A: A
  readonly _X: X
  readonly _URI: URI
  constructor(public readonly fx: HKT<X>[F], public readonly f: (x: X) => Free<F, A>) {}
  map<B>(f: (a: A) => B): Free<F, B> {
    return new Impure<F, B, X>(this.fx, x => this.f(x).map(f))
  }
  of<B>(b: B): Free<F, B> {
    return of<F, B>(b)
  }
  ap<B>(fab: Free<F, (a: A) => B>): Free<F, B> {
    return fab.chain(f => this.map(f)) // <- derived
  }
  chain<B>(f: (a: A) => Free<F, B>): Free<F, B> {
    return new Impure<F, B, X>(this.fx, x => this.f(x).chain(f))
  }
  foldMap<M extends HKTS>(monad: StaticMonad<M>, f: NaturalTransformation<F, M>): HKT<A>[M] {
    return monad.chain<X, A>((x: X) => this.f(x).foldMap(monad, f), f<X>(this.fx))
  }
}

export function of<F extends HKTS, A>(a: A): Free<F, A> {
  return new Pure<F, A>(a)
}

export function liftFree<F extends HKTS, A>(fa: HKT<A>[F]): Free<F, A> {
  return new Impure<F, A, A>(fa, of)
}

Usage
//
// Adapted from http://typelevel.org/cats/datatypes/freemonad.html
//

// Create an ADT representing your grammar

import { Option, fromNullable } from 'fp-ts/lib/Option'

declare module 'fp-ts/lib/HKT' {
  interface HKT<A> {
    KVStoreA: KVStoreA<A>
  }
}

export class KVStoreA<A> {
  _A: A
}

class Put<T> extends KVStoreA<void> {
  constructor(public readonly key: string, public readonly value: T) {
    super()
  }
}

class Get<T> extends KVStoreA<Option<T>> {
  constructor(public readonly key: string) {
    super()
  }
}

class Delete extends KVStoreA<void> {
  constructor(public readonly key: string) {
    super()
  }
}

//
// Free your ADT
//

// Create a Free type based on your ADT

type KVStore<A> = Free<'KVStoreA', A>

// Create smart constructors using liftF

function put<T>(key: string, value: T): KVStore<void> {
  return liftFree<'KVStoreA', void>(new Put(key, value))
}

function get<T>(key: string): KVStore<Option<T>> {
  return liftFree<'KVStoreA', Option<T>>(new Get<T>(key))
}

function del(key: string): KVStore<void> {
  return liftFree<'KVStoreA', void>(new Delete(key))
}

// Update composes get and set, and returns nothing
function update<T>(key: string, f: (t: T) => T): KVStore<void> {
  return get<T>(key).chain(o => o.map(v => put<T>(key, f(v))).getOrElse(() => of<'KVStoreA', void>(undefined)))
}

// Build a program

// program :: Free<"KVStoreA", Option<number>>
const program = put('wild-cats', 2)
  .chain(() => update('wild-cats', (n: number) => n + 12))
  .chain(() => put('tame-cats', 5))
  .chain(() => get<number>('wild-cats'))
  .chain(n => del('tame-cats').map(() => n))

//
// Write a compiler for your program
//

import * as identity from 'fp-ts/lib/Identity'

// a very simple (and imprecise) key-value store
const kvs: { [key: string]: any } = {}

// the program will crash if a key is not found,
// or if a type is incorrectly specified
function compile<A>(fa: KVStoreA<A>): identity.Identity<A> {
  if (fa instanceof Put) {
    console.log(`put(${fa.key}, ${fa.value})`)
    kvs[fa.key] = fa.value
    return identity.of(undefined) as any
  } else if (fa instanceof Get) {
    console.log(`get(${fa.key})`)
    return identity.of(fromNullable(kvs[fa.key])) as any
  } else if (fa instanceof Delete) {
    console.log(`del(${fa.key})`)
    delete kvs[fa.key]
    return identity.of(undefined) as any
  }
  throw new Error('never')
}

// Run your program

const result = program.foldMap(identity, compile).value

console.log(result) // =>

/*
put(wild-cats, 2)
get(wild-cats)
put(wild-cats, 14)
put(tame-cats, 5)
get(wild-cats)
del(tame-cats)
Some(14)
*/

This is even better than flow-static-land.
With the above implementation I can follow this Scala tutorial about free monads as if it were ts 😄

Nice. We can adapt it in order to write an official tutorial.
Some considerations:
(1) I don't like the way Scala implements unions using inheritance. TypeScript supports actual unions, I'd love to use them with ADTs
(2) the interpreter is not type safe (note how many any in the compile implementation above)
(3) no exhaustivity checks in the body of interpreters
(4) there's a lot of boilerplate involved
As a possible solution I propose this pattern (which uses phantom types)
// ...definition of Free as above...

// additional definitions

export interface ADT<URI extends HKTS, A> {
  _A: A
  _URI: URI
}

export type AnyADT = ADT<any, any>
export type UriOf<FA extends AnyADT> = FA['_URI']
export type TypeOf<FA extends AnyADT> = FA['_A']

export function liftADT<FA extends AnyADT>(fa: FA): Free<UriOf<FA>, TypeOf<FA>> {
  return liftFree(fa as any)
}

Usage
ADTs
//
// Adapted from http://blog.scalac.io/2016/06/02/overview-of-free-monad-in-cats.html
//

export class Degree {
  readonly value: number
  constructor(d: number) {
    this.value = (d + 360) % 360
  }
}

export class Position {
  constructor(
    public readonly x: number,
    public readonly y: number,
    public readonly heading: Degree
  ) {}
}

export type InstructionURI = 'Instruction'

export class Forward implements ADT<InstructionURI, Position> {
  readonly _tag: 'Forward'
  readonly _A: Position
  readonly _URI: InstructionURI
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) {}
}

export class RotateRight implements ADT<InstructionURI, Position> {
  readonly _tag: 'RotateRight'
  readonly _A: Position
  readonly _URI: InstructionURI
  constructor(
    public readonly position: Position,
    public readonly degree: Degree
  ) {}
}

Lifting
export type Instruction = Forward | RotateRight

declare module 'fp-ts/lib/HKT' {
  interface HKT<A> {
    Instruction: Instruction
  }
}

// less boilerplate here using liftADT
const forward = (position: Position, length: number) => liftADT(new Forward(position, length))
const right = (position: Position, degree: Degree) => liftADT(new RotateRight(position, degree))

(type-safe) Interpreters
const computation = {
  forward(position: Position, length: number): Position {
    const degree = position.heading.value
    if (degree === 0) {
      return new Position(position.x + length, position.y, position.heading)
    } else if (degree === 90) {
      return new Position(position.x, position.y + length, position.heading)
    } else if (degree === 180) {
      return new Position(position.x - length, position.y, position.heading)
    } else if (degree === 270) {
      return new Position(position.x, position.y - length, position.heading)
    }
    throw new Error(`Unkonwn direction ${degree}`)
  },
  right(position: Position, degree: Degree): Position {
    return new Position(position.x, position.y, new Degree(position.heading.value - degree.value))
  }
}

import * as identity from 'fp-ts/lib/Identity'

function interpretIdentity(fa: Instruction): identity.Identity<TypeOf<typeof fa>> {
  if (fa instanceof Forward) {
    return identity.of(computation.forward(fa.position, fa.length))
  } else {
    return identity.of(computation.right(fa.position, fa.degree))
  }
}

const start = new Position(0, 0, new Degree(90))

const program1 = (start: Position) => {
  return forward(start, 10)
    .chain(p1 => right(p1, new Degree(90)))
    .chain(p2 => forward(p2, 10))
}

console.log(program1(start).foldMap(identity, interpretIdentity).value) // => Position { x: 10, y: 10, heading: Degree { value: 0 } }

import * as option from 'fp-ts/lib/Option'

const nonNegative = (position: Position): option.Option<Position> =>
  position.x >= 0 && position.y >= 0 ? option.some(position) : option.none

function interpretOption(fa: Instruction): option.Option<TypeOf<typeof fa>> {
  if (fa instanceof Forward) {
    return nonNegative(computation.forward(fa.position, fa.length))
  } else {
    return nonNegative(computation.right(fa.position, fa.degree))
  }
}

const program2 = (start: Position) => {
  return forward(start, 10)
    .chain(p1 => right(p1, new Degree(90)))
    .chain(p2 => forward(p2, 10))
    .chain(p1 => right(p1, new Degree(180)))
    .chain(p2 => forward(p2, 20)) // Here the computation stops, because result will be None
}

console.log(program2(start).foldMap(option, interpretOption)) // => None

Is there a way to hide some of the boilerplate code for the ADT such as _tag, _A, and _URI?
export class Forward implements ADT<InstructionURI, Position> {
  readonly _tag: 'Forward'
  readonly _A: Position
  readonly _URI: InstructionURI
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) {}
}

_tag can be removed if we test using instanceof. Also we can make ADT a class
export class ADT<URI extends HKTS, A> {
  readonly _A: A
  readonly _URI: URI
}

and then
export class InstructionADT<A> extends ADT<'Instruction', A> {}

export class Forward extends InstructionADT<Position> {
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) { super() }
}

export class RotateRight extends InstructionADT<Position> {
  constructor(
    public readonly position: Position,
    public readonly degree: Degree
  ) { super() }
}

@danielepolencic I'm not satisfied. I think we can remove _URI by currying liftADT, also need a solution for composing several sets of instructions (Composing section of the tutorial). Working on an amended version..

Turns out I need some boilerplate in order to get the best type safety

_tag (at the type level AND at runtime) in order to use switch and get exhaustivity checks in the base interpreters
_URI (at the type level AND at runtime) in order to use switch and get exhaustivity checks in the composed interpreter

Fortunately we need less boilerplate than Scala while composing ADTs and interpreters.
Here's the complete tutorial
// adapted from http://okmij.org/ftp/Computation/free-monad.html

import { HKT, HKTS } from 'fp-ts/lib/HKT'
import { FantasyMonad, StaticMonad } from 'fp-ts/lib/Monad'
import { identity as id } from 'fp-ts/lib/function'

export type NaturalTransformation<F extends HKTS, G extends HKTS> = <A>(fa: HKT<A>[F]) => HKT<A>[G]

declare module 'fp-ts/lib/HKT' {
  interface HKT<A> {
    Free: Free<any, A>
  }
}

export const URI = 'Free'

export type URI = typeof URI

export type Free<F extends HKTS, A> = Pure<F, A> | Impure<F, A, any>

export class Pure<F extends HKTS, A> implements FantasyMonad<URI, A> {
  static of = of
  readonly _tag = 'Pure'
  readonly _F: F
  readonly _A: A
  readonly _URI: URI
  constructor(public readonly a: A) {}
  map<B>(f: (a: A) => B): Free<F, B> {
    return new Pure<F, B>(f(this.a))
  }
  of<B>(b: B): Free<F, B> {
    return of<F, B>(b)
  }
  ap<B>(fab: Free<F, (a: A) => B>): Free<F, B> {
    return fab.chain(f => this.map(f)) // <- derived
  }
  chain<B>(f: (a: A) => Free<F, B>): Free<F, B> {
    return f(this.a)
  }
  foldMap<M extends HKTS>(monad: StaticMonad<M>, f: NaturalTransformation<F, M>): HKT<A>[M] {
    return monad.of(this.a)
  }
}

export class Impure<F extends HKTS, A, X> implements FantasyMonad<URI, A> {
  static of = of
  readonly _tag = 'Impure'
  readonly _F: F
  readonly _A: A
  readonly _X: X
  readonly _URI: URI
  constructor(public readonly fx: HKT<X>[F], public readonly f: (x: X) => Free<F, A>) {}
  map<B>(f: (a: A) => B): Free<F, B> {
    return new Impure<F, B, X>(this.fx, x => this.f(x).map(f))
  }
  of<B>(b: B): Free<F, B> {
    return of<F, B>(b)
  }
  ap<B>(fab: Free<F, (a: A) => B>): Free<F, B> {
    return fab.chain(f => this.map(f)) // <- derived
  }
  chain<B>(f: (a: A) => Free<F, B>): Free<F, B> {
    return new Impure<F, B, X>(this.fx, x => this.f(x).chain(f))
  }
  foldMap<M extends HKTS>(monad: StaticMonad<M>, f: NaturalTransformation<F, M>): HKT<A>[M] {
    return monad.chain<X, A>((x: X) => this.f(x).foldMap(monad, f), f<X>(this.fx))
  }
}

export function of<F extends HKTS, A>(a: A): Free<F, A> {
  return new Pure<F, A>(a)
}

export function liftF<F extends HKTS, A>(fa: HKT<A>[F]): Free<F, A> {
  return new Impure<F, A, A>(fa, of)
}

export interface ADT<URI extends HKTS, A> {
  readonly _A: A
  readonly _URI: URI
}

export type AnyADT = ADT<any, any>
export type UriOf<FA extends AnyADT> = FA['_URI']
export type TypeOf<FA extends AnyADT> = FA['_A']

export function liftADT<FA extends AnyADT>(fa: FA): Free<UriOf<FA>, TypeOf<FA>> {
  return liftF(fa as any)
}

export function inject<G extends HKTS>(): <F extends G>(free: Free<F, any>) => Free<G, TypeOf<typeof free>> {
  return id
}

//
// Adapted from http://blog.scalac.io/2016/06/02/overview-of-free-monad-in-cats.html
//

export class Degree {
  readonly value: number
  constructor(d: number) {
    this.value = (d + 360) % 360
  }
}

export class Position {
  constructor(
    public readonly x: number,
    public readonly y: number,
    public readonly heading: Degree
  ) {}
}

export const InstructionURI = 'Instruction'

export type InstructionURI = typeof InstructionURI

export class Forward {
  readonly _tag = 'Forward'
  readonly _A: Position
  readonly _URI = InstructionURI
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) { }
}

export class Backward {
  readonly _tag = 'Backward'
  readonly _A: Position
  readonly _URI = InstructionURI
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) { }
}

export class RotateRight {
  readonly _tag = 'RotateRight'
  readonly _A: Position
  readonly _URI = InstructionURI
  constructor(
    public readonly position: Position,
    public readonly degree: Degree
  ) { }
}

export class Show {
  readonly _tag = 'Show'
  readonly _A: void
  readonly _URI = InstructionURI
  constructor(
    public readonly position: Position
  ) { }
}

export type Instruction = Forward | Backward | RotateRight | Show

declare module 'fp-ts/lib/HKT' {
  interface HKT<A> {
    Instruction: Instruction
  }
}

export const forward = (position: Position, length: number) => liftADT(new Forward(position, length))
export const backward = (position: Position, length: number) => liftADT(new Backward(position, length))
export const right = (position: Position, degree: Degree) => liftADT(new RotateRight(position, degree))
export const show = (position: Position) => liftADT(new Show(position))

const computation = {
  forward(position: Position, length: number): Position {
    const degree = position.heading.value
    if (degree === 0) {
      return new Position(position.x + length, position.y, position.heading)
    } else if (degree === 90) {
      return new Position(position.x, position.y + length, position.heading)
    } else if (degree === 180) {
      return new Position(position.x - length, position.y, position.heading)
    } else if (degree === 270) {
      return new Position(position.x, position.y - length, position.heading)
    }
    throw new Error(`Unkonwn direction ${degree}`)
  },
  backward(position: Position, length: number): Position {
    return computation.forward(
      new Position(position.x, position.y, new Degree(position.heading.value + 180)),
      length
    )
  },
  right(position: Position, degree: Degree): Position {
    return new Position(position.x, position.y, new Degree(position.heading.value - degree.value))
  }
}

import * as identity from 'fp-ts/lib/Identity'

export function interpretIdentity(fa: Instruction): identity.Identity<TypeOf<typeof fa>> {
  switch (fa._tag) {
    case 'Forward' :
      return identity.of(computation.forward(fa.position, fa.length))
    case 'Backward' :
      return identity.of(computation.backward(fa.position, fa.length))
    case 'RotateRight' :
      return identity.of(computation.right(fa.position, fa.degree))
    case 'Show' :
      console.log('interpretIdentity', fa.position)
      return identity.of(fa.position)
  }
}

const start = new Position(0, 0, new Degree(90))

const program1 = (start: Position) => {
  return forward(start, 10)
    .chain(p1 => right(p1, new Degree(90)))
    .chain(p2 => forward(p2, 10))
    .chain(p3 => show(p3))
}

console.log('--program1--')
program1(start).foldMap(identity, (fa: Instruction) => interpretIdentity(fa)).value // => interpretIdentity Position { x: 10, y: 10, heading: Degree { value: 0 } }

import * as option from 'fp-ts/lib/Option'

const nonNegative = (position: Position): option.Option<Position> =>
  position.x >= 0 && position.y >= 0 ? option.some(position) : option.none

export function interpretOption(fa: Instruction): option.Option<TypeOf<typeof fa>> {
  switch (fa._tag) {
    case 'Forward' :
      return nonNegative(computation.forward(fa.position, fa.length))
    case 'Backward' :
      return nonNegative(computation.backward(fa.position, fa.length))
    case 'RotateRight' :
      return nonNegative(computation.right(fa.position, fa.degree))
    case 'Show' :
      console.log('interpretOption', fa.position)
      return option.some(fa.position)
  }
}

const program2 = (start: Position) => {
  return forward(start, 10)
    .chain(p1 => right(p1, new Degree(90)))
    .chain(p2 => forward(p2, 10))
    .chain(p1 => right(p1, new Degree(180)))
    .chain(p2 => forward(p2, 20)) // Here the computation stops, because result will be None
    .chain(p3 => show(p3))
}

console.log('--program2--')
program2(start).foldMap(option, (fa: Instruction) => interpretOption(fa))

// Composing

export const PencilInstructionURI = 'PencilInstruction'

export type PencilInstructionURI = typeof PencilInstructionURI

export class PencilUp {
  readonly _tag = 'PencilUp'
  readonly _A: void
  readonly _URI = PencilInstructionURI
  constructor(
    public readonly position: Position
  ) { }
}

export class PencilDown {
  readonly _tag = 'PencilDown'
  readonly _A: void
  readonly _URI = PencilInstructionURI
  constructor(
    public readonly position: Position
  ) { }
}

export type PencilInstruction = PencilUp | PencilDown

declare module 'fp-ts/lib/HKT' {
  interface HKT<A> {
    PencilInstruction: PencilInstruction
  }
}

export const pencilUp = (position: Position) => liftADT(new PencilUp(position))
export const pencilDown = (position: Position) => liftADT(new PencilDown(position))

export type LogoAppURI = InstructionURI | PencilInstructionURI

export type LogoApp = Instruction | PencilInstruction

const inj = inject<LogoAppURI>()

const program3 = (start: Position) => {
  return inj(forward(start, 10))
    .chain(p1 => right(p1, new Degree(90)))
    .chain(p2 => {
      return inj(pencilUp(p2))
        .chain(() => forward(p2, 10))
        .chain(p3 => {
          return inj(pencilDown(p3))
            .chain(() => backward(p3, 20))
            .chain(p4 => show(p4))
        })
    })
}

export function penInterpretIdentity(fa: PencilInstruction): identity.Identity<TypeOf<typeof fa>> {
  if (fa instanceof PencilUp) {
    console.log(`stop drawing at position ${JSON.stringify(fa.position)}`)
    return identity.of(undefined)
  } else {
    console.log(`start drawing at position ${JSON.stringify(fa.position)}`)
    return identity.of(undefined)
  }
}

export function interpret(fa: LogoApp): identity.Identity<TypeOf<typeof fa>> {
  switch (fa._URI) {
    case InstructionURI :
      return interpretIdentity(fa)
    case PencilInstructionURI :
      return penInterpretIdentity(fa)
  }
}

console.log('--program3--')
program3(start).foldMap(identity, (fa: LogoApp) => interpret(fa))
/*
stop drawing at position {"x":0,"y":10,"heading":{"value":0}}
start drawing at position {"x":10,"y":10,"heading":{"value":0}}
interpretIdentity Position { x: -10, y: 10, heading: Degree { value: 180 } }
*/

// should raise an error
// program3(start).foldMap(identity, (fa: LogoApp) => interpretIdentity(fa))

This looks very interesting to me. Thanks for that!
A few comments:

variables starting with an _ are generally assumed to be private. I think in this case making the field private would not help much since we would not be able to access the value inside the switch. Is there a specific reason why you want to prefix them with an underscore?
I could still use the trick you mentioned in this comment? I'd like to make the code easy to read. I think this is really hard to digest:

export class Forward {
  readonly _tag = 'Forward'
  readonly _A: Position
  readonly _URI = InstructionURI
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) { }
}

I'm concerned that I end up duplicating code in the name of the class and in the _tag property. I guess I could have myInstance.constructor.name instead of _tag or instanceof if the name of the class is the same as the _tag property. I don't think Typescript is smart enough to narrow down the selection with that, though.

Is there a specific reason why you want to prefix them with an underscore?

Because they were phantom types so far
readonly _tag: 'Forward'
readonly _A: Position
readonly _URI: InstructionURI

However in the last version _tag and _URI are also runtime values so we could change their name
readonly _A: Position // <= this is still a phantom type

readonly tag = 'Forward'
readonly URI = InstructionURI

I could still use the trick you mentioned in this comment?

Not sure that trick is useful anymore since we also need runtime values (or maybe there is another way..)
export class ADT<URI extends HKTS, T, A> {
  readonly _A: A
  readonly tag: T
  readonly URI: URI
  constructor(URI: URI, tag: T) {
    this.URI = URI
    this.tag = tag
  }
}

// new, a bit verbose
export class Forward extends ADT<'Instruction', 'Forward', Position> {
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) { super('Instruction', 'Forward') } // <= these values are duplicated but at least are type-checked
}

// old
export class Forward {
  readonly _A: Position
  readonly tag = 'Forward'
  readonly URI = InstructionURI
  constructor(
    public readonly position: Position,
    public readonly length: number
  ) { }
}

I'm concerned that I end up duplicating code in the name of the class and in the _tag property

I'm afraid is unavoidable: you need both the runtime value and the literal type
class MyClass {
  tag = MyClass.constructor.name
}

const y = new MyClass()
y.tag // <- type `string`, we need the literal type `'MyClass'`

Thanks for clarifying.
I'd like to try out the code, can this be merged as a PR?

@danielepolencic https://github.com/gcanti/fp-ts/pull/56

Thanks for this!
🎉 🍾 💪

I have another question that has to do more with the theory behind free(r) monads than this library.
Let's assume that I implemented the logo language as showed above. I also have the following program written in the DSL:
const program1 = (start: Position) => {
  return forward(start, 10)
    .chain(p1 => right(p1, new Degree(90)))
    .chain(p2 => forward(p2, 10))
    .chain(p3 => show(p3))
}

I'd like to write an interpreter that instead of returning a value as such, it returns a representation of the program (AST). In other words, I'd like to have an interpreter that at the end of the computation produces the following abstract syntax tree:
[
  {action: 'forward', position: {...}, length: 10},
  {action: 'right', position: {...}, degree: 90},
  {action: 'forward', position: {...}, length: 10},
  {action: 'show'}
]

I tried to play with the identity interpreter and the best I could come up with is this:
interface INode {
  action: string
  position: INode | Position
  length?: number
  degree?: Degree
}

export function interpretIdentity(fa: Instruction): identity.Identity<INode> {
  switch (fa._tag) {
    case 'Forward' :
      return identity.of({action: 'forward', position: fa.position, length: fa.length});
    case 'Backward' :
      return identity.of({action: 'backward', position: fa.position, length: fa.length});
    case 'RotateRight' :
      return identity.of({action: 'right', position: fa.position, degree: fa.degree})
    case 'Show' :
      return identity.of({action: 'show', position: fa.position})
  }
}

which returns the following recursive data structure:
{
  "action": "show",
  "position": {
    "action": "forward",
    "position": {
      "action": "right",
      "position": {
        "action": "forward",
        "position": {
          "x": 0,
          "y": 0,
          "heading": {
            "value": 90
          }
        },
        "length": 10
      },
      "degree": {
        "value": 90
      }
    },
    "length": 10
  }
}

Let's assume now I want to evaluate the AST, is there a way I can feed that back to the free monad, but this time using the real identity interpreter with computations?

@danielepolencic not sure I'm following, program1 is already an "AST" that you can interpret. Why another AST?

The second AST is serialised and can be persisted / shipped out of the app.

I see. Theoretically the signature of your interpreter is not correct though
export function interpretIdentity(fa: Instruction): identity.Identity<INode>

should be
export function interpretIdentity<A>(fa: Instruction<A>): identity.Identity<A>
// or
export function interpretIdentity(fa: Instruction): identity.Identity<free.TypeOf<typeof fa>>

that is, the codomain of a natural transformation should be a functor.
Indeed the type of result here is void
// result :: void
const result = program1(start).foldMap(identity, (fa: Instruction) => interpretNode(fa)).value

so result can't contain any recursive data structure.
In order to build an AST we could use State
export interface ForwardStatement {
  action: 'forward',
  length: number
}

export interface BackwardStatement {
  action: 'backward',
  length: number
}

export interface RotateRightStatement {
  action: 'right',
  degree: Degree
}

export interface ShowStatement {
  action: 'show'
}

export type Statement =
  | ForwardStatement
  | BackwardStatement
  | RotateRightStatement
  | ShowStatement

export type Program = Array<Statement>

export class AST<A> extends state.State<Program, A> {}

function push(s: Program, n: Statement): Program {
  return s.concat(n)
}

export function interpretAST(fa: Instruction): AST<free.TypeOf<typeof fa>> {
  switch (fa._tag) {
    case 'Forward' :
      return new AST(s => [
        computation.forward(fa.position, fa.length),
        push(s, {action: 'forward', length: fa.length})
      ])
    case 'Backward' :
      return new AST(s => [
        computation.backward(fa.position, fa.length),
        push(s, {action: 'backward', length: fa.length})
      ]);
    case 'RotateRight' :
      return new AST(s => [
        computation.right(fa.position, fa.degree),
        push(s, {action: 'right', degree: fa.degree})
      ])
    case 'Show' :
      return new AST(s => [
        undefined,
        push(s, {action: 'show'})
      ])
  }
}

const result: [void, Program] = program1(start).foldMap(state, (fa: Instruction) => interpretAST(fa)).run([])

console.log(JSON.stringify(result[1], null, 2))
/*
[
  {
    "action": "forward",
    "length": 10
  },
  {
    "action": "right",
    "degree": {
      "value": 90
    }
  },
  {
    "action": "forward",
    "length": 10
  },
  {
    "action": "show"
  }
]
*/

function run(start: Position, program: Program): Position {
  let out = start
  program.forEach(statement => {
    switch (statement.action) {
      case 'forward' :
        out = computation.forward(out, statement.length)
        break
      case 'backward' :
        out = computation.backward(out, statement.length)
        break
      case 'right' :
        out = computation.right(out, statement.degree)
        break
      case 'show' :
        // do nothing
    }
  })
  return out
}

console.log('--program from ast--')
console.log(run(start, result[1])) // => Position { x: 10, y: 10, heading: Degree { value: 0 } }

A better option than run is writing a function from the AST to free.Free<"Instruction", Position | void>. Then you can use any interpreter
function fromStatement(position: Position, statement: Statement): free.Free<"Instruction", Position | void> {
  switch (statement.action) {
    case 'forward' :
      return forward(position, statement.length)
    case 'backward' :
      return backward(position, statement.length)
    case 'right' :
      return right(position, statement.degree)
    case 'show' :
      return show(position)
  }
}

export function fromProgram(program: Program): (start: Position) => free.Free<"Instruction", Position | void> {
  return start => {
    if (program.length === 0) {
      throw new Error('Invalid program')
    }
    let out = fromStatement(start, program[0])
    program.slice(1).forEach(statement => {
      out = out.chain(p => {
        if (p) {
          return fromStatement(p, statement)
        }
        throw new Error('Runtime error: unknown position')
      })
    })
    return out
  }
}

const program4 = fromProgram(result[1])
console.log('--fromProgram--')
program4(start).foldMap(identity, (fa: Instruction) => interpretIdentity(fa)).value // => interpretIdentity Position { x: 10, y: 10, heading: Degree { value: 0 } }

the codomain of a natural transformation should be a functor.

I guess I lack the basics. Thanks for clarifying, this is really helpful.

@danielepolencic
a natural transformation
maps a functor (input domain) to another functor (output domain aka codomain)
export type NaturalTransformation<F extends HKTS, G extends HKTS> = <A>(fa: HKT<A>[F]) => HKT<A>[G]
That's it! :)

@danielepolencic Another example of free applied to a real world task: drawing on canvas
I made two drawings (https://github.com/gcanti/graphics-ts/blob/master/example/index.ts)

one with IO (module canvas https://github.com/gcanti/graphics-ts/blob/master/src/canvas.ts)
the other one with Free (module free-canvas https://github.com/gcanti/graphics-ts/blob/master/src/free-canvas.ts)

Note: the free version is slower, even if I cheated writing an impure interpreter (returns Identity, should return IO)
ioSnowflake:<PHONE_NUMBER>46875ms
freeSnowflake:<PHONE_NUMBER>875ms

Nice example, thanks!

Note: the free version is slower, even if I cheated writing an impure interpreter (returns Identity, should return IO)

I'm aware of it. I read a paper somewhere suggesting that the quadratic nature of Free could be simplified to improve performance.
Tbh, I'm not too concerned about performance as long as the code is safe and horizontally scalable (might not be doable for graphics-ts).

I'm aware of it. I read a paper somewhere suggesting that the quadratic nature of Free could be simplified to improve performance.

I suspect my first version of free is pretty naive in this respect (and probably also not stack safe), I'll try to dig into this as soon as I have some time

I think this was the article I read it from: http://mandubian.com/2015/04/09/freer/

@gcanti regarding the stack, in a nodejs context, one may rely on that:
https://medium.com/@dai_shi/tail-call-optimization-tco-in-node-v6-e2492c9d5b7c


Separate Install Packages From Main Provisioning Script

The main provisioning script currently has a few packages that are downloaded and installed via wget. These need to be moved into a separate package file and iterated through just like the standard packages and ppas.

PPA packages are now separated into individual scripts to allow easier modification in the future. Now, I can do the same with each of these!


Implement react component's responsiveness

Currently, the plugin is not adjusted to the size of the window. So the goal is to implement an automatic plugin's zoom adjustment according to the window size.
The zoom functionality is already implemented, but adjusted manually only.
https://github.com/A-Lehmann-Elektro-AG/solar-flow-grafana/blob/ee7abbdbf5d23afd3fa9aa9a77dd318e8bd93cb0/src/components/energyFlow/index.tsx#L86
Possible Solution: Grafana Forum | How to access panel dimensions from the panel editor?

[!NOTE]
Refer to CONTRIBUTING.md for contributing instructions

hey can i work on this issue

hey can i work on this issue

Hey, @Sauhard74! Yes, you are welcome to work on it :)

Can you assign the issue to me?

Hi @Sauhard74. How's it going? Are you still working on it?


Upgrade terraform-provider-cloudflare to v3.34.0

This PR was generated by the upgrade-provider tool.

Fixes #328

https://github.com/pulumi/pulumi-cloudflare/pull/333 needs to be debugged and merged before this PR can land.

This is now several updates behind. I think it would be easier to simply create a new PR.


[macOS] Replace keyboard shortcut does not work

VS Code Version: 1.12.2
OS Version: macOS 10.12.5

Replace keyboard shortcut does not work.
{
  "command": "editor.action.startFindReplaceAction",
  "key": "alt+cmd+f"
}

Choosing the corresponding menu option works fine.
Find shortuct also works fine.
{
  "command": "actions.find",
  "key": "cmd+f"
}

@Deilan did you use any third party application on your machine, for example spectacle which takes over alt+cmd+f.

@rebornix You're right, I do. And that causes the issue. Thanks for help!


Support non TornadoScopeManager in traced_function decorator

Fix https://github.com/uber-common/opentracing-python-instrumentation/issues/80

Coverage increased (+0.3%) to 79.009% when pulling 6fcee94d26821aa00e2d63a05fdfb2031783d161 on condorcet:traced-function-fix into b49ea9397e3a97fb849d3c8559f39ff835f4b6ff on uber-common:master.

I am not clear why dummy context is necessary. Wrapping context in Tornado's StackContext is very Tornado-specific thing, as far as I know. In case of other framework, isn't it sufficient to call tracer.start_active()?

The idea of these dummy context is just fallback to span_in_context behavior with auto closing scope after exiting. It can be useful when we use ThreadLocalContextManager with regular functions. Closing scope in this case need to restore previous context. So you can write something like this:
with span_in_stack_context(parent):
    ...
    with span_in_stack_context(spanA):
        ...
        # scope of `spanA`
        with span_in_stack_context(spanB):
            ...
            # scope of `span B`
        # again scope of `spanA`
....
# scope of `parent`

@yurishkuro Actually I try to solve problem of using decorator with regular functions and ThreadLocalScopeManager ( span_in_stack_context wraps call of original function). Another way is add same logic on traced_function layer instead of request_context. Maybe it's better way, what do you think?

I wish we could kill this dependency on StackContext, it makes instrumentation for Tornado completely different from all other frameworks.  I think it would be preferable to move the logic to @traced_function and not pushing all code paths through request_in_context, which is Tornado-only thing.

I wish we could kill this dependency on StackContext, it makes instrumentation for Tornado completely different from all other frameworks. I think it would be preferable to move the logic to @traced_function and not pushing all code paths through request_in_context, which is Tornado-only thing.

@yurishkuro Done

Hi @condorcet,
I've submitted condorcet/opentracing-python-instrumentation#1 in purpose to slightly polish this PR.


Cannot find player ID

Hi,
when I tried to download the video at "https://dl.dropboxusercontent.com/u/29092637/interview.html", youtube-dl returns an error "Cannot find player ID".
Thanks.

Output:
C:\youtube-dl> youtube-dl.exe "https://dl.dropboxusercontent.com/u/29092637/interview.html" --verbose
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'https://dl.dropboxusercontent.com/u/29092637/interview.html', u'--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out cp437, pref cp1252
[debug] youtube-dl version 2016.03.14
[debug] Python version 2.7.10 - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg N-74113-gcdb0225, ffprobe N-74113-gcdb0225
[debug] Proxy map: {}
[generic] interview: Requesting header
WARNING: Falling back on generic information extractor.
[generic] interview: Downloading webpage
[generic] interview: Extracting information
ERROR: Cannot find player ID; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
File "youtube_dl\extractor\generic.pyo", line 1314, in _real_extract
File "youtube_dl\compat.pyo", line 248, in compat_etree_fromstring
File "youtube_dl\compat.pyo", line 237, in _XML
File "xml\etree\ElementTree.pyo", line 1642, in feed
File "xml\etree\ElementTree.pyo", line 1506, in _raiseerror
ParseError: mismatched tag: line 46, column 4
Traceback (most recent call last):
File "youtube_dl\YoutubeDL.pyo", line 668, in extract_info
File "youtube_dl\extractor\common.pyo", line 320, in extract
File "youtube_dl\extractor\generic.pyo", line 1374, in _real_extract
File "youtube_dl\extractor\brightcove.pyo", line 220, in _extract_brightcove_urls
File "youtube_dl\extractor\brightcove.pyo", line 151, in _build_brighcove_url
ExtractorError: Cannot find player ID; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

Thanks for the report. This will be fixed in the next version.


Dates In Statistics in Epoch Format

Describe the bug
Dates are in epoch format in the Statistics dashboard.
date_from          Date_to
1590969600000<PHONE_NUMBER>000
Expected behavior
Should be human readable date.
How to reproduce it (as minimally and precisely as possible):
Steps to reproduce the behavior:

Go to Statistics dashboard.
See error

Environment

TeslaMate version: 1.20.1
Type of installation: Docker
OS TeslaMate is installed on: Pop!OS 20.10
User OS & Browser: Win10 Edge Dev
Others:

Those fields are used for the links and should be hidden, but then the cannot used for the links due to a bug in Grafana. We are waiting to get that bug fixed.


accept header in request is not correct for TAXII spec

dgreenwood@Davids-MacBook-Pro-2 ~ % curl -X 'GET' \
  'http://<IP_ADDRESS>:8000/api/taxii2/' \
  -H 'accept: application/taxii+json;version=2.1' \
  -H 'Authorization: Basic bm9fYWNjZXNzX3VzZXI6dGVzdGluZzEyMw=='
{"title":"Could not satisfy the request Accept header.","http_status":406,"details":{"content":{"message":"Could not satisfy the request Accept header.","code":"not_acceptable"}}}%                                                            dgreenwood@Davids-MacBook-Pro-2 ~ % curl -X 'GET' \
  'http://<IP_ADDRESS>:8000/api/taxii2/' \
  -H 'accept: application/json' \
  -H 'Authorization: Basic bm9fYWNjZXNzX3VzZXI6dGVzdGluZzEyMw=='
{"title":"Arango TAXII Server","description":"https://github.com/muchdogesec/arango_taxii_server/","contact":"noreply@dogesec.com","api_roots":[]}%

As per the TAXII spec:
https://docs.oasis-open.org/cti/taxii/v2.1/taxii-v2.1.html

however, the server does not accept application/taxii+json;version=2.1 and only responds to application/json as per the example shown above.
The server should only accept requests where this is application/taxii+json;version=2.1

fixed in adding-tests branch

can you alter in the swagger ui?
shows application/taxii+json should be application/taxii+json;version=2.1


Define new product features for specific types of Storage Managers

Need these features to handle role_allows for already defined toolbar buttons
This PR together with https://github.com/ManageIQ/manageiq-ui-classic/pull/1020 is bugfix for https://bugzilla.redhat.com/show_bug.cgi?id=1440108

@gtanzillo could you merge this, we have a UI PR that is blocked and we want to try to get that into this release.  Thx, Dan

Fine backport details:
$ git log -1
commit ba62829409da5ff3aca7c959bde521c94c24714c
Author: Gregg Tanzillo<EMAIL_ADDRESS>Date:   Thu Apr 20 11:40:00 2017 +0200

    Merge pull request #14745 from jzigmund/define_features_for_storage_managers

    Define new product features for specific types of Storage Managers
    (cherry picked from commit a8afcb8e7a08236dabb75bdeaae12ad9a3159090)


[replace] does not replace metadata (dependencies)

I have a branch of Servo with this override:
[replace]
"hyper:0.8.1" = {git = "https://github.com/servo/hyper", branch = "url-1.0"}

In that git branch, the Cargo.toml for hyper contains:
[dependencies]
url = "1.0"

However, hyper with my replaced sourced is built with url 0.5.9, which is the dependency declared in the original un-replaced hyper. Cargo.lock even shows this:
[[package]]
name = "hyper"
version = "0.8.1"
source = "git+https://github.com/servo/hyper?branch=url-1.0#353217402264578933dca89c0e7f210052c552a5"
dependencies = [
 […]
 "url 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

Where dependencies does not match what’s in the Cargo.toml file at source.
(Specifying an additional replacement for "url:0.5.9" = {git = "https://github.com/servo/rust-url", branch = "1.0.0-pretending-to-be-0.5.9"} worked, but I was trying to remove it now that url 1.0.0 is on crates.io.)

I unfortunately can't seem to reproduce this situation in a test case of Cargo. Is there a branch I could check out or an easy way for me to reproduce this locally?

I'm facing a similar issue and ./mach clean doesn't help either. Here's my situation in short:
git clone https://github.com/servo/unicode-bidi
git clone https://github.com/servo/servo

then:

Edit unicode-bidi/Cargo.toml and bump the version
Update dependency version in components/layout/text.rs
Add following line to [replace] table in servo/Cargo.toml:

"unicode-bidi:0.3.0" = { path = "../servo-unicode-bidi" }

Here's the result:
$ ./mach clean

$ ./mach build --dev
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: no matching version `^0.3` found for package `unicode-bidi` (required by `layout`)
location searched: registry https://github.com/rust-lang/crates.io-index
versions found: 0.2.5, 0.2.4, 0.2.3, ...
Build FAILED in 0:00:03

@behnam currently [replace] only works with crates that already exist on crates.io, and it looks like 0.3.0 doesn't exist on crates.io?

Right, @alexcrichton. The 0.3.0 version is something I have locally and want to test servo against before publishing.
In servo/Cargo.toml, I see this:
[replace]
# If you need to temporarily test Servo with a local fork of some upstream
# crate, add that here. Use the form:
#
#     "<crate>:<version>" = { path = "/path/to/local/checkout" }

which sounds like exactly what I need [replace] for: overriding the source (path instead of crates.io) for the specific version for the whole build.

Interesting part is that I get a warning: package replacement is not used: https://github.com/rust-lang/crates.io-index#... if I add a replace entry with a version that's not required. But, when the version is required by some of the components, the warning goes away, but a few seconds into the ./mach build I get the error: no matching version ... error.

@behnam ah yeah if you want to work with unpublished crates currently Cargo doesn't have support for that, but you may be interested in https://github.com/rust-lang/rfcs/pull/1969 which adds support.

Okay, got it. But wondering what this comment in servo/Cargo.toml means, then:
# If you need to temporarily test Servo with a local fork of some upstream
# crate, add that here. Use the form:

Yeah as long as the version of the crate listed in path is the same as it is in the lock file, then you should be good to go.

I unfortunately can't seem to reproduce this situation in a test case of Cargo. Is there a branch I could check out or an easy way for me to reproduce this locally?

Closing due to inactivity, if this is still an issue, please reopen with more details.

I think that the solution to this is often to use [patch] instead of [replace]


How to run job on a certain time?

I'm not sure this lib has this feature for no example like this in the docs. Here's my requirement:
1.Set a certain time to trigger a job(it's just to send a local notification, in fact)
2.Cancel all jobs sometimes
Any hint will be appreciated!

If you want to send a local notification it's better to schedule it using some of the notification libraries. This library is more for repeating background tasks.


Upgrade Cassandra driver version

Updated the Cassandra driver version to 3.9.0

@arnenissen Please create Jira ticket for this version upgrade and add the JIRA ID in your commit message as well.

Hi @madhawa-gunasekara ,
I created the Jira ticket amd updated the pull request.

Thanks for your contribution.


[HUDI-4766] Fix HoodieFlinkClusteringJob

Allow rollbacks if required during clustering
Allow size to be defined in Long instead of Integer
Fix bug where clustering will produce files of 120MB in the same filegroup
Added clean task
Fix scheduling config to be consistent with that with compaction
Fix filter mode getting ignored issue
Add --instant-time parameter
Prevent no execute() calls exception from being thrown (clustering & compaction)

Change Logs
Describe context and summary for this change. Highlight if any code was copied.
Impact
Describe any public API or user-facing feature change or any performance impact.
Risk level: none | low | medium | high
Choose one. If medium or high, explain what verification was done to mitigate the risks.
Contributor's checklist

[ ] Read through contributor's guide
[ ] Change Logs and Impact were stated clearly
[ ] Adequate tests were added if applicable
[ ] CI passed

@danny0405 Added the changes that you suggested. Thank you.


ebiten: enable to detect a gamepad type like PlayStation, Xbox, and so on

Requested by @wasedaigo
Now we can do a similar thing by parsing the gamepad name, but this is very fragile.

I investigated this a while back and wrote a blog post on it:
https://www.silbinarywolf.com/post/189934380218/you-cant-just-query-if-a-controller-is-for-xbox
tldr; Xbox controllers gamepad button positions are fairly stable but Playstation and other gamepad button layouts vary from gamepad to gamepad. So your best bet is using this community sourced database of gamepad names / layouts if you were going to implement something like this.


Sometimes sending stimuli fails the first time after connection and everything locks up

If it works then it will present hundreds of trials happily in a loop:
In [9]: while True:
        hZP.send_samples(hardwareTriggered=False)
        sleep(0.5)
        hZP.stop_opto_stim()
        sleep(0.3)
        n+=1

But other times it locks up with a DAQmx error and in MATLAB too there is a problem. This seems to happen if the current NI Task is an on-demand task or no task has so far been created. If a stimulus was already played (e.g. Zap site) then after that it seems to run.

Ah.... It's setting a hardware trigger when it shouldn't
In [19]: hZP.send_samples(hardwareTriggered=False)
Creating clocked AO task on Dev2
Configuring a hardware trigger on line PFI0


UnsupportedOperationException

[   +2 ms] :app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
[ +104 ms] :app:compileDebugJavaWithJavac
[        ] :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
[+2191 ms] Note: Some input files use or override a deprecated API.
[   +1 ms] Note: Recompile with -Xlint:deprecation for details.
[        ] Note: Some input files use unchecked or unsafe operations.
[        ] Note: Recompile with -Xlint:unchecked for details.
[ +210 ms] :app:compileDebugNdk UP-TO-DATE
[        ] :app:compileDebugSources
[+2060 ms] :app:transformClassesWithJarMergingForDebug
[+6174 ms] :app:transformClassesWithMultidexlistForDebug
[+32583 ms] :app:transformClassesWithDexForDebug FAILED
[  +18 ms] FAILURE: Build failed with an exception.
[   +1 ms] * What went wrong:
[   +1 ms] Execution failed for task ':app:transformClassesWithDexForDebug'.
[        ] > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
[   +6 ms] * Try:
[   +1 ms] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[        ] BUILD FAILED
[        ] Total time: 56.249 secs
[ +701 ms] "flutter run" took 69,503ms.
Gradle build failed: 1

#0      throwToolExit (package:flutter_tools/src/base/common.dart:29)
#1      _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:304)
<asynchronous suspension>
#2      buildGradleProject (package:flutter_tools/src/android/gradle.dart:237)
<asynchronous suspension>
#3      buildApk (package:flutter_tools/src/commands/build_apk.dart:82)
<asynchronous suspension>
#4      AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:361)
<asynchronous suspension>
#5      FlutterDevice.runHot (package:flutter_tools/src/resident_runner.dart:249)
<asynchronous suspension>
#6      HotRunner.run (package:flutter_tools/src/run_hot.dart:199)
<asynchronous suspension>
#7      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:345)
<asynchronous suspension>
#8      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:241)
<asynchronous suspension>
#9      FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:181)
<asynchronous suspension>
#10     CommandRunner.runCommand (package:args/command_runner.dart:194)
<asynchronous suspension>
#11     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:279)
<asynchronous suspension>
#12     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:109)
#13     new Future.sync (dart:async/future.dart:222)
#14     CommandRunner.run (package:args/command_runner.dart:109)
#15     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:162)
#16     run.<anonymous closure> (package:flutter_tools/executable.dart:143)
<asynchronous suspension>
#17     AppContext._run (package:flutter_tools/src/base/context.dart:76)
<asynchronous suspension>
#18     AppContext.runInZone.<anonymous closure> (package:flutter_tools/src/base/context.dart:66)
#19     _rootRun (dart:async/zone.dart:1120)
#20     _CustomZone.run (dart:async/zone.dart:1001)
#21     runZoned (dart:async/zone.dart:1467)
#22     AppContext.runInZone (package:flutter_tools/src/base/context.dart:65)
#23     run (package:flutter_tools/executable.dart:114)
<asynchronous suspension>
#24     main (package:flutter_tools/executable.dart:67)
<asynchronous suspension>

$ flutter doctor
[✓] Flutter (on Linux, locale en_US.UTF-8, channel master)
    • Flutter at /home/reyer/reyer/flutter/master
    • Framework revision 0044ea2dbb (34 hours ago), 2017-10-02 00:06:24 -0700
    • Engine revision bdfedcc26f
    • Tools Dart version 1.25.0-dev.11.0

[✓] Android toolchain - develop for Android devices (Android SDK 26.0.2)
    • Android SDK at /home/reyer/Android/Sdk
    • Platform android-26, build-tools 26.0.2
    • ANDROID_HOME = /home/reyer/Android/Sdk
    • Java binary at: /home/reyer/.local/share/umake/android/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] Android Studio (version 2.3)
    • Android Studio at /home/reyer/.local/share/umake/android/android-studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] IntelliJ IDEA Community Edition (version 2017.2)
    • Flutter plugin version 17.0
    • Dart plugin version 172.4155.35

[✓] Connected devices
    • Android SDK built for x86 • emulator-5558 • android-x86 • Android 7.0 (API 24) (emulator)
    • emulator-5556             • emulator-5556 • android-x86 • Android 4.1.2 (API 16) (emulator)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)

We need more information to be able to do anything here, like what was the code you were trying to compile? What are the steps to reproduce?

did you ever figure this out ?

Sorry folks, it was in October. I just don't remember.

Ok I'm going to close this. Thanks for filing the issue, don't hesitate to file a new one if you see this again!


move Heating/Cooling season to a non northern-hemisphere-based system

Currently, the heating/cooling season description (gv.is_heating_season, gv.seasonhours) is based on the assumption that winter is in December and summer in July. This is only true for the northern hemisphere. And the tropics don't have heating/cooling seasons, so, we need a smarter way to do this.

@JIMENOFONSECA I would like to hear your thoughts on this...

I will include the gv.season_hours as input parameters in the demand script. This is something that the user should specify always. I imagine this as a calendar option, where first, the users selects if there is heating season (a tick box), i the tick box is activated. the user should select the beginning and end of the heating season. i.e., 12.09.16    -    15.05.17. if the user does not indicate anything (the tickbox is off). then we will consider the entire year as cooling and no heating...

does it make sense to include a cooling season and a heating season?
also, season_hours is a bit confusing as a name... can we refactor the code a bit? I propose:

gv contains start_date_heating_season, end_date_heating_season, start_date_cooling_season, end_date_cooling_season.
this get's translated to two ndarrays of booleans: is_heating_enabled and is_cooling_enabled

what do you think?

yep we an transform it to boolean. what is necessary is to include a new modification to the demand toolbox GUI. see my last comment on how it could be.
yes, it is necessary. heating season and cooling season mean "politically" when you are allowed to heat your building or cool it down. USA, europe (depending on the country) have an specific way to deal with these dates.

OK. So I will implement it like that in a branch i251-heating-cooling-seasons including an option for the gui.

Please wait for my major changes in demand calculation. Thank you.
#220

moving this to next milestone as it might interfere with @gabriel-happle 's work

@daren-thomas is this still required?

@gabriel-happle - how would this now work? do we want to sit together and look at it?

I see this is something we should definately have to run CEA for Singapore and other locations... chanign to priority 1

The solution will be to select these parameters from the interface in arcgis of the demand script. It should give the option to the user of a calendar to indicate when the heating season starts and ends, when the cooling season starts and ends. and..if there is a heating season or not, and if there is a cooling season or not.

OK. I have a problem here. @gabriel-happle do I understand this correctly: we don't actually have any way to indicate cooling season? it's just defined as not-heating-season?
And how does the seasonhours work?
I'm trying to refactor this into four dates:

heating-season-start
heating-season-end
cooling-season-start
cooling-season-end

and the option to set them to blank / None or something if no heating season or cooling season can be defined. or even better: like @JIMENOFONSECA said, two more variables:

has-heating-season
has-cooling-season

These variables will be part of the configuration file cascade that I'm busy making.

Also. Assuming we assign a date to heating-season-start: e.g. 2017-08-01. Which hour is this then? first hour in the day? last hour in the day?

Check out PR #671 (cascading configuration files) - this includes a unittest that replaces the current gv.is_heating_season function with one that works on the four dates described above.
Oh. BTW. we don't have a cooling season. And the bounds are not clear. Can @gabriel-happle and @JIMENOFONSECA take a look??

@daren-thomas the original definition of the cooling and heating season was directly given as hour of the year in the globalvars. So maybe from there we can check which hour is exactly meant.
self.seasonhours = [3216,6192]   should be 00:00 on that particular day.
Yes, we do not have cooling season and heating season, from what I understand is that there are legal rules on when you are allowed to start heating your building in Switzerland.
But I agree, we should be able to define four dates.
And maybe also some temperature rules, like the ones mentioned below:
https://www.hausinfo.ch/de/home/recht/mietrecht/nutzung/heizen.html

@gabriel-happle how do we proceed? I don't think we can make this milestone - we'd need to test. I have a unittest in the branch that shows an example of calculating the gv.is_heating_season function. I don't think the opposite is necessarily cooling season either... and rules would be good, of course!

I also don't think we can make this milestone

@daren-thomas do you still want to do this in the May sprint? Or move it to the next one? Should we talk next week?

@gabriel-happle yes, let's talk. No. I think we should move it to the July sprint and use the rest of the may sprint to finish testing the stuff we already coded - as opposed to starting new stuff. BUT, I do think we could start thinking about it now...

OK. So...

we need to move gv.is_heating_season usage in calc_simple_temp_control to use the version in helpers.
use demand sections to figure out if heating season or not (same for cooling season)
main thermal loads function uses this:

 def get_hours():
    ...:     t = 6000
    ...:     for i in xrange(8760):
    ...:         yield (t+i) % 8760

and we figure out starting t based on some logic tbd

we decided: we need a region-specific database for heating and cooling seasons. maybe even a control systems database (can we maybe do this in an incremental issue?).
Long term target for refactoring: A HeatingController and CoolingController?


Issues with contentHost and @import from another domain

I have a couple of @import references in my CSS for Google web fonts:
@import url("http://fonts.googleapis.com/css?family=Alfa+Slab+One");
@import url("http://fonts.googleapis.com/css?family=Corben");
RequestReduce is erroring when processing these @imports. The issue is that it is changing the host name to the CDN I have specified in my contentPath attribute. and therefore the server is returning a 404/3.
System.ApplicationException: There were errors reducing http://hatchplatform.com/CSS/All.less::http://hatchplatform.com/demo/~Style/CSS:: ---> System.InvalidOperationException: RequestReduce had problems accessing http://www.hatchcdn.com/css?family=Alfa+Slab+One. Error Message from WebClient is: The remote server returned an error: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
Ideally RequestReduce should leave these @imports as they are rather than processing them because Google web-fonts issues different CSS depending on the browser that is being used.

Hi Marcus,
I'll look more closely tonight but take a look at the latest version of RequestReduce if you are not already using it. I recently changed the host rewriting logic to ignore external hosts. As far as the user agent detection google uses, that can be an issue. RR's request will bring back css fonts that should work with almost all browsers however it will not include @media wrappers if thats what you wanted. I can look at extending the api to allow you to specify urls to be ignored like whats done for JS and CSS.

Just checked this against the latest RR version and the Host injection bug looks to be addressed but I really should be checking the @Import urls against RequestReduce.Api.CssFilter.IgnoreTarget so you can bypass these urls if you want. I'm considering that a bug and will get into the next bug fix release. Thanks Marcus!

Ah good stuff. Many thanks!
On Wed, Feb 8, 2012 at 3:43 PM, Matt Wrock <
<EMAIL_ADDRESS>
wrote:

Just checked this against the latest RR version and the Host injection bug
looks to be addressed but I really should be checking the @Import urls
against RequestReduce.Api.CssFilter.IgnoreTarget so you can bypass these
urls if you want. I'm considering that a bug and will get into the next bug
fix release. Thanks Marcus!

Reply to this email directly or view it on GitHub:
https://github.com/mwrock/RequestReduce/issues/133#issuecomment-3869542

I'm a bit confused as to how this actually works...
To clarify the original request, if my original stylesheet had the following:
@import url("http://fonts.googleapis.com/css?family=Alfa+Slab+One");
@import url("otherstuff-classes.css");
body { blah blah }

Then I believe the output should be:
@import url("http://fonts.googleapis.com/css?family=Alfa+Slab+One");
.otherstuff { blah blah }
body { blah blah }

I specifically want the Google webfonts @import declaration to be ignored because Google serves a different stylesheet depending on the browser useragent.
Is this how it works? And if so, how do I configure RR to ignore the fonts.googleapis.com domain?
cheers
Marcus

Hi Mark,
I've added the line to ignore the fonts.googleapis.com @import which is working (i.e. the import is ignored) but unfortunately not as intended. I want the @import line to remain in the RR'd stylesheet because I need this to be processed by the viewing browser since Google delivers a different response for different browsers. Is there any way to make it work this way?
cheers
Marcus

I've been looking into this a bit more. There are a couple of issues that I believe are bugs:

I have 2 stylesheets. The first doesn't contain any @imports. The second has google font apis @import statements at the top so that they are processed properly. When RR processes my 2 stylesheets, the @import statements are ignored as per the configuration but because they are in the 2nd stylesheet, they are appended to the RR'd CSS after the first stylesheet - hence they stop working. I know this is a bit of an edge case, but in order to work correctly, RR needs to move the @import statements to the beginning of the final CSS.

Tracing through the RR code as it processes my stylesheets, the minifier seems to remove all @import statements from the code completely in HeadResourceReducerBase.cs line 41.

Hi Marcus,
Sorry for not getting back to you sooner on this. Yes this does appear to be an issue. I had overlooked the fact when adding ignore logic to the imports that if they are not at the top of the processed css, they won't be applied by the browser. Unfortunately, moving them to the top can also have some negative consequences - not for fonts in your case, but potentially for other styles since the order in which styles appear is key to rendering.
A couple suggestions:

Move the font @imports to their own separate css file and have RR ignore that file.
Move your @imports inline

I realize that having RR expand the imports opts you out of the browser specific implementation. I'm curious - other than not wrapping the fonts in @Media rules targeting the screen, are there other browser specific markup that google applies for different browsers?


Could not install packages due to an OSError: [Errno 13] Permission denied

Hi there I'm trying to install few packages through pip but I'm getting this error:
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/nix/store/f2x987ir7wmyxbil5qw25dh6wscxkmrb-python3-3.10.9-env/lib/python3.10/site-packages/text_unidecode' Check the permissions.
I checked permissions in this folder and it should done but I'm not sure where the problem lies.
Is there easy way to install packages using pip or everything has to be done with config.nix or nix-env?

everything has to be done with config.nix?

pip isn't expected to work in Nix world. Maybe you can make it work on a bet, but you'll have to fight your way through. Please use the (superior) way of Nix: https://nixos.org/manual/nixpkgs/stable/#python

everything has to be done with config.nix?
pip isn't expected to work in Nix world. Maybe you can make it work on a bet, but you'll have to fight your way through. Please use the (superior) way of Nix: https://nixos.org/manual/nixpkgs/stable/#python

I thought so.


chore: root, core, icons

What:

Additional issues:

:tada: This PR is included in version 6.1.4 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:

:tada: This PR is included in version 1.0.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:


Add Restart/backup Planer

Is your feature request related to a problem? Please describe.
Currently, the lack of an automated Restart/Backup planner requires server administrators to manually restart the server and create backups. This is especially problematic for maintaining server performance and ensuring data security. Without regular restarts, the server can become unstable, leading to potential crashes that could disrupt gameplay. Additionally, without frequent backups, there is a significant risk of data loss, particularly in the event of an unexpected server failure. Automating these tasks would greatly enhance the efficiency of server management, reduce the likelihood of server issues, and protect valuable game data."
Describe the solution you'd like
The solution I envision is a fully automated Restart and Backup Planner integrated into the web interface. This feature would allow administrators to schedule server restarts at specific times, with customizable intervals (daily, weekly, or custom). It should include automated notifications to players before each restart and a graceful shutdown option to ensure that gameplay is not abruptly interrupted.
Describe alternatives you've considered
"In considering alternatives, I looked at manual management, which offers control but is time-consuming and prone to human error. Another option was using server-side scripts with Cron jobs or Task Scheduler, providing flexibility but lacking integration with the web interface, making it harder to manage. I also considered external backup and monitoring services, which are convenient but introduce reliance on third parties and potential costs.

Yeah not a bad idea. I can definitely see how having control of that from within the web interface would be handy, even just for scheduling regular restarts like you mentioned. I'll probably just make a simple interface to wrap cron. But yeah should certainly be doable!
I'm currently working on some pretty big changes to this project on the dev branch with a lot of things in the backend currently in-flux. See, dev-1.8 Todos.txt if you're curious. I want to get those things done first before starting on this new feature because A) they'll help with the development of this feature and B) this will just make more sense to add after those things are in place.
All that to say, I don't know if this will make it into the v1.8.0 release, but def make it into 1.9! But yeah thanks for bringing it up! I'm going to put it in the Todo.txt backlog for right now and will update this issue as things progress.


Move generator into the upstream Kibana repo?

Right now its challenging to version this, maybe we should move it into the Kibana repo itself?

+1. I like the way babel does this using a mono-repo approach (https://github.com/babel/babel/tree/master/packages). It's got a packages folder with all the different npm packages, then a script to release them.


Make this a template repository

With template in the name, a "template repository" seems a like a great option. :smile:
https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository

And I see that it actually already is. Woops. Sorry for the noise.


Support source attibute on Diagnostic

@dbaeumer I don't see this support in the latest vscode-eslint version, has this changed been published yet?

@egamma no, I didn't because of the problems with VSCode not supporting different extension versions. I published a patched version that has that support now.

Thanks!
Am 29.02.2016 um 15:40 schrieb Dirk B?umer <notifications<EMAIL_ADDRESS>@egammahttps://github.com/egamma no, I didn't because of the problems with VSCode not supporting different extension versions. I published a patched version that has that support now.

Reply to this email directly or view it on GitHubhttps://github.com/Microsoft/vscode-eslint/issues/22#issuecomment-190236397.


[terra-application-navigation] Rollup Nav Item Selection Jumps Page

Bug Report
Description

When selecting an item from the navigation option when the navigation tabs are collapsed, the rendered content jumps on the page.
Steps to Reproduce

Go to terra-ui.com or https://engineering.cerner.com/terra-framework/raw/tests/terra-application-navigation/application-navigation/stated-demo
Adjust viewport to collapse navigation into rolled-up menu
Select different menu item to re-route
See page jumping

Additional Context / Screenshots

https://share.getcloudapp.com/wbu0bApA
https://share.getcloudapp.com/5zu1Nejv
Environment

Browser Name and Version: Chrome Version 80.0.3987.163
Operating System and version (desktop or mobile): macOS Mojave 10.14.6

actually, it looks like it's an issue with the secondary navigation not presenting when already within that navigation tab: https://share.getcloudapp.com/E0ubj7dp
In this video, I am on the Tests tab. I am trying to change the test page & it's not displaying the other test page options.

I am not sure whether this has been fixed or it happens at specific viewport widths but it-seems to be working fine. I tested same test example that is given in issue description page navigation was happening without jump as shown in the above video links.

@supreethmr did you try when the primary navigation also renders a secondary navigation?

@supreethmr did you try when the primary navigation also renders a secondary navigation?

yes, I also tried the above scenario as well and I was not able to observe the page jump as shown in videos provided on Issue. But I noticed secondary navigation was not showing up on selecting same navigation item in primary navigation ( Clicking on Tests opens components list in secondary navigation but after selection of component secondary navigation closes and re-clicking the Tests tab again is not re-opening the secondary navigation ) .

 I wonder if it's related to the drawer functionality of terra-dev-site. It seems when it's a certain size, the drawer collapses the secondary nave and it doesn't open when navigation to a new main nav:
https://share.getcloudapp.com/lluDEvNW

It seems when it's a certain size, the drawer collapses the secondary nave and it doesn't open when navigation to a new main nav

I tested this with all view ports and secondary navigation opens on each new main navigation item select. as Shown in above attached video secondary navigation was not opening on re-selecting main navigation item tests. This is because of condition  if (activeNavigationItemPath !== navigationItemKey) in _DevSiteNavigation.jsx which will prevent router from update when the navigation item path is same.
I am still not able to reproduce the jump behavior ( it looks like dark overlay opens and closes fast on main navigation item select ). let me know if there are any specific width in which i can try to reproduce this issue.
by Seeing the video attached I did check application navigation code to see if there any CSS transitions that might be causing this Blink behavior on page selection. I found that we have transform style defined for drawer menu . So in order to check this options I need help on reproducing it consistently.

@supreethmr, Ryan asked me to take another look at this issue since it's been awhile. Since logging this, my chrome version has updated from  80.0.3987.163 to 83.0.4103.61 and I am no longer able to re-produce this issue. Not sure if it was a browser issue or a browser + external monitor issue but it seems to have resolved itself. I am going to close this. If it re-appears, we can re-open/log a new issue. 😄  Thanks for looking into this!


docker in pre-build is failing: unknown flag: --label

Checklist

[X] I've looked through the issues and pull requests for similar reports

Describe your issue
docker --version
Docker version 20.10.18, build b40c2f6b5d
cross build
unknown flag: --label
See 'docker --help'.

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default
                           "/home/jack/.docker")
  -c, --context string     Name of the context to use to connect to the daemon
                           (overrides DOCKER_HOST env var and default context set
                           with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level
                           ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default
                           "/home/jack/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default
                           "/home/jack/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/home/jack/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  builder     Manage builds
  compose*    Docker Compose (Docker Inc., 2.11.1)
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.

To get more help with docker, check out our guides at https://docs.docker.com/go/guides/

Error:
   0: could not run container
   1: when building custom image
   2: when pre-building
   3: `docker buildx build --label 'org.cross-rs.for-cross-target=x86_64-unknown-linux-gnu' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=/home/jack/Dev/cv.defi.digital-backend' --tag localhost/cross-rs/cross-custom-cv.defi.digital-backend:x86_64-unknown-linux-gnu-8e548-pre-build --build-arg 'CROSS_CMD=apt-get update' --build-arg 'CROSS_DEB_ARCH=amd64' --file /home/jack/Dev/cv.defi.digital-backend/target/x86_64-unknown-linux-gnu/Dockerfile.x86_64-unknown-linux-gnu-custom --output 'type=docker' /home/jack/Dev/cv.defi.digital-backend` failed with exit status: 125

Location:
   /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/core/src/convert/mod.rs:557

Note: CROSS_CMD=apt-get update

What target(s) are you cross-compiling for?
x86_64-unknown-linux-gnu
Which operating system is the host (e.g computer cross is on) running?

[ ] macOS
[ ] Windows
[X] Linux / BSD
[ ] other OS (specify in description)

What architecture is the host?

[X] x86_64 / AMD64
[ ] arm32
[ ] arm64 (including Mac M1)

What container engine is cross using?

[X] docker
[ ] podman
[ ] other container engine (specify in description)

cross version
cross 0.2.4 (596b223 2022-10-03)
Example
 [build]
 xargo = false
 build-std = false
 default-target = "x86_64-unknown-linux-gnu"
 zig = "2.17"
 pre-build = ["apt-get update"]

Additional information / notes
No response

Ok installing docker-buildx solves the issue. The error information is misleading though

Ok installing docker-buildx solves the issue. The error information is misleading though

Unfortunately for Docker, Podman, Nerdctl, etc., all of them have higher priority for flags when reporting errors than invalid commands, so it's very confusing. If you ever have a container engine that doesn't support buildkit, however, you can use CROSS_CONTAINER_ENGINE_NO_BUILDKIT=1 to use $engine build rather than $engine buildx build.
I wish the errors were better as well:
docker aaa --bbb
unknown flag: --bbb


💡[Feature]: Adding Number plate detectin system.

Is there an existing issue for this?

[X] I have searched the existing issues

Feature Description
This feature involves adding a Number Plate Detection System to the project. The system will use computer vision and Optical Character Recognition (OCR) techniques to detect, recognize, and extract text from vehicle license plates in real-time or from images.
The implementation would utilize technologies like OpenCV for image processing and Tesseract OCR for text recognition. It will be capable of detecting number plates from various angles, improving accuracy in text extraction even in challenging environments.
Use Case
This feature will be highly beneficial for security systems, automated toll collection, parking management, and traffic monitoring. The system can capture number plate data, store it in a database, and trigger alerts for specific plates, such as blacklisted vehicles.
Benefits

Automation: Eliminates the need for manual intervention in vehicle monitoring systems, improving efficiency.
Security: Enhances security by identifying and tracking vehicles.
Time-saving: Speedy detection and recognition will significantly reduce wait times at toll booths, parking lots, or security checks.
Scalability: The system can be integrated into various domains such as smart cities, parking management systems, and automated security systems, benefiting a wider community.

Add ScreenShots

Priority
High
Record

[X] I have read the Contributing Guidelines
[X] I'm a GSSOC'24 contributor
[X] I want to work on this issue

its already there


Release 2.7.0: new pin on matplotlib-base<3.6.0

pin activated in https://github.com/ESMValGroup/ESMValTool/pull/2830
pin motivated by https://github.com/ESMValGroup/ESMValTool/pull/2800
pin deactivated before release: no (change and close if this changes before final stable release)

ALSO remember to up the pin on esmvalcore to 2.7.0

also for release @zklaus added iris-esmf-regrid in the conda env :+1:

also xgboost>1.6.1 https://github.com/ESMValGroup/ESMValTool/pull/2780

changes forded in https://github.com/conda-forge/esmvaltool-suite-feedstock/pull/12 that just got merged, so this is closing :door:


Issues when converting tensorflow built-in keras-based models to tensorflow lite

Hello Tensorflow Support
I am contacting you because I am getting the following error while converting a model created with Keras embedded in Tensorflow to Tensorflow Lite.
The model I created used the basic structure of Bidirectional LSTM with dropout, regularization, and dense layers.
I've attached the code to convert my model to Tensorflow Lite and the message when the error occurred.
I hope this will solve your problem.
Best regards,
Yonghyun Lee
[Code to convert my model to Tensorflow Lite].
import tensorflow as tf
model = tf.keras.models.load_model(“./input_h5/input.h5”, compile=False, safe_mode=False)
tf.saved_model.save(model, './input_h5/saved_model_dir')
converter = tf.lite.TFLiteConverter.from_saved_model(“./input_h5/saved_model_dir”)
tflmodel = converter.convert()
with open(“./output_tflite/output.tflite”, “wb”) as file:
file.write(tflmodel)
[Error Message]
2024-08-22 11:09:03.490341: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
W0000 00:00:1724292544.933616 42872 tf_tfl_flatbuffer_helpers.cc:392] Ignored output_format.
W0000 00:00:1724292544.934307 42872 tf_tfl_flatbuffer_helpers.cc:395] Ignored drop_control_dependency.
2024-08-22 11:09:04.937226: I tensorflow/cc/saved_model/reader.cc:83] Reading SavedModel from: ./input_h5/saved_model_dir
2024-08-22 11:09:04.941589: I tensorflow/cc/saved_model/reader.cc:52] Reading meta graph with tags { serve }
2024-08-22 11:09:04.941738: I tensorflow/cc/saved_model/reader.cc:147] Reading SavedModel debug info (if present) from: ./input_h5/saved_model_dir
2024-08-22 11:09:04.961054: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled
2024-08-22 11:09:04.964133: I tensorflow/cc/saved_model/loader.cc:236] Restoring SavedModel bundle.
2024-08-22 11:09:05.075893: I tensorflow/cc/saved_model/loader.cc:220] Running initialization op on SavedModel bundle at path: ./input_h5/saved_model_dir
2024-08-22 11:09:05.112269: I tensorflow/cc/saved_model/loader.cc:462] SavedModel load for tags { serve }; Status: success: OK. Took 174732 microseconds.
2024-08-22 11:09:05.185339: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:268] disabling MLIR crash reproducer, set env var MLIR_CRASH_REPRODUCER_DIRECTORY to enable.
loc(fused[“ReadVariableOp:”, “sequential_11_1/bidirectional_22_1/backward_lstm_22_1/while/lstm_cell_1/add_1/ReadVariableOp@sequential_11_1_bidirectional_22_1_backward_lstm_22_1_while_body_613”]): error: missing attribute 'value'
LLVM ERROR: Failed to infer result type(s).

@yonghyunee ,
Could you please provide the tensorflow version you are using. This issue was resolved in latest tensorflow v2.17 and tf-nightly. Please try with those versions and let me know if you are facing the same issue. Thank you!

Hello
I succeeded in converting it to keras h5 -> tensorflow lite using the method you told me above. In the process of applying the model, the following error appears, so can you tell me the solution to this error?
[Error]
Exception in thread Thread-2 (receive_message):
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/root/gait_phase_estimation/main.py", line 27, in receive_message
interpreter.allocate_tensors()
File "/usr/lib/python3.10/site-packages/tflite_runtime/interpreter.py", line 531, in allocate_tensors
return self._interpreter.AllocateTensors()
RuntimeError: Select TensorFlow op(s), included in the given model, is(are) not supported by this interpreter. Make sure you apply/link the Flex delegate before inference. For the Android, it can be resolved by adding "org.tensorflow:tensorflow-lite-select-tf-ops" dependency. See instructions: https://www.tensorflow.org/lite/guide/ops_selectNode number 15 (FlexTensorListReserve) failed to prepare.Select TensorFlow op(s), included in the given model, is(are) not supported by this interpreter. Make sure you apply/link the Flex delegate before inference. For the Android, it can be resolved by adding "org.tensorflow:tensorflow-lite-select-tf-ops" dependency. See instructions: https://www.tensorflow.org/lite/guide/ops_selectNode number 15 (FlexTensorListReserve) failed to prepare.
[Model Convert Code]
import tensorflow as tf
model = tf.keras.models.load_model("./input_h5/input.h5", compile=False, safe_mode=False)
tf.saved_model.save(model, './input_h5/saved_model_dir')
converter = tf.lite.TFLiteConverter.from_saved_model("./input_h5/saved_model_dir")
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]
converter._experimental_lower_tensor_list_ops = False
converter.experimental_enable_resource_variables = True
tflmodel = converter.convert()
with open("./output_tflite/output.tflite", "wb") as file:
file.write(tflmodel)
[Versions]
Where the tensorflow-lite model runs :
python 3.10.14
tflite-runtime 2.14.0
Where the tensorflow-lite model converter runs :
python 3.11.9
tf_keras                     2.16.0
tf-nightly                   2.18.0.dev20240822
tf_nightly_intel             2.18.0.dev20240822
tensorflow                   2.17.0
tensorflow-intel             2.17.0
Thank you
Best regards,
Yonghyun Lee

Hi, @yonghyunee
I apologize for the delayed in my response, if possible could you please help me with your Google colab notebook where you created your model with bidirectional LSTM with dropout, regularization, and dense layers which will help us to investigate this issue further from our end ?
Thank you for your cooperation and patience.


Fix nontemplated package names

Hey guys. You forgot to template two of your files, leading to lots of compile errors.

oooops. thanks a lot @bijancn. will check how CI missed that. probably these sneaked in while it was red due to zio RC upgrade.

oooops. thanks a lot @bijancn. will check how CI missed that. probably these sneaked in while it was red due to zio RC upgrade.


Test against flutter/flutter HEAD for each flutter/engine presubmit

So we're sure that the engine can always be rolled into flutter/flutter. Currently, this is difficult to achieve due to how we setup the golden files (and probably some other tests).

This is fixed by https://github.com/flutter/engine/pull/8664


Also get access to the headers set by superagent

For my tests I also needed access to the headers set by the 'set' method.
This is how I resolved that, but it might not be the most correct way?
If you think this feature is nice, but the implementation isn't feel free to suggest a more correct implementation, I'll make sure it works as you suggest then!

Give the headers to the fixture method might be the good way :smiley_cat: :v:
Could add tests and update README with this feature please ?

Thanks for the fast review! Working on readme and tests.
Not sure what you mean with 'Give the headers to the fixture method'
Is that not what I am doing? Tips are appreciated!

Yes, it's what you're doing, it's good for me :wink:

@fdubost: ready for another review :D

It seems to be OK for me :+1:
Thank you @oponder :smiley:

Tag v1.5.0. I can't publish this on npm now because only @oziks have the rights and he is on holiday :smile_cat:

thats ok :) take your time

Available on npm under 1.7.0 version.


Autorest Regen Preview to 3.0.0-alpha.20230620.2 by Mingzhe Huang from refs/pull/3498/head

Triggered from https://github.com/Azure/autorest.csharp/pull/3498

API change check
API changes are not detected in this pull request.


How to write to flash safely

I‘m using freertos(SMP) + lvgl .
There is 3 tasks.
    TaskHandle_t lvgl_task_handle;
    xTaskCreate(lv_timer_task_handler, "lvgl_task", 4096, NULL, (tskIDLE_PRIORITY + 4), &lvgl_task_handle);
    vTaskCoreAffinitySet(lvgl_task_handle, (1 << 0));

     TaskHandle_t video_flush_handler;
     xTaskCreate(video_flush_task, "video_flush", 4096, NULL, (tskIDLE_PRIORITY + 3), &video_flush_handler);
     vTaskCoreAffinitySet(video_flush_handler, (1 << 1));

    TaskHandle_t main_task_handler;
    xTaskCreate(main_task, "main_task", 4096, NULL, (tskIDLE_PRIORITY + 2), &main_task_handler);
    vTaskCoreAffinitySet(main_task_handler, (1 << 0));

The program can run successfully.
When a button click on screen. change a global value.Then write flash in main_task.
    uint32_t ints = save_and_disable_interrupts();
    flash_range_erase(FLASH_TARGET_OFFSET, FLASH_SECTOR_SIZE);
    flash_range_program(FLASH_TARGET_OFFSET, tmp, FLASH_PAGE_SIZE);
    restore_interrupts (ints);

when code running flash_range_erase , the program crash ,But I can't see any logs。
Use Clion debug pico swd, the pc point running to 0xfffffffe .
I also tried the UF2 program method, Still failing.
I also tried using multicore_lockout_start_blocking multicore_lockout_end_blocking.But failed.Maybe there are some errors in my code.
How to write flash safely?
Can someone help me?
Thanks !

Have a look at the sdk documentation under pico_flash.  There are mechanisms for doing this, I have never used them though.  There is also the option of using the method you already have, but you need to make sure to use the victim init function on the secondary core.  I am not sure how that will work with freertos, but the pico_flash functions mention freertos and what to look out for.

best to visit https://forums.raspberrypi.com/viewforum.php?f=143 for questions

Have a look at the sdk documentation under pico_flash. There are mechanisms for doing this, I have never used them though. There is also the option of using the method you already have, but you need to make sure to use the victim init function on the secondary core. I am not sure how that will work with freertos, but the pico_flash functions mention freertos and what to look out for.

Thank for reply.I searched carefully again and found that there are some functions  more suitable in pico_flash.
Put flash_safe_execute_core_init(); at the begin of code in core 1.
When I want to write flash,using flash_safe_execute like bellow:
flash_safe_execute(write_flash,&background_arc_color,2000);
Well, it worked！


Test particles

Open branch for a new general test particle implementation.

Seems to be stable enough for master.


⚠ Bofrost.at has degraded performance

In c77ce4c, Bofrost.at (https://www.bofrost.at) experienced degraded performance:

HTTP code: 200
Response time: 1666 ms

Resolved: Bofrost.at performance has improved in 19dbd68.


MudTabs: Add IconColor, IconSize and IconViewBox properties to MudTabPanel

Description
MudTabs: Add IconColor, IconSize and IconViewBox properties to MudTabPanel
As our app grows, we combine multiple MudTabs on a sinlge page and use the Icon color and size
as visual indicators. When something needs attention it is instantly visible, like a big red icon.
Right now, we do it like this, but it's a bit much when you have multiple tab panels, I also
have to maintain the tab panel text.
It also makes binding icon properties easier and cleaner.

How Has This Been Tested?

[X] Visual inspection of doc examples.

Types of changes

[ ] Bug fix (non-breaking change which fixes an issue)
[X] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[X] Code tweak in MudTabs.razor

Checklist:

[X] The PR is submitted to the correct branch (dev).
[X] My code follows the code style of this project.
[X] I've added relevant tests.

I am not sure. Whenever many customization options have to be added I see a wasted opportunity of adding a single render fragment parameter

I am not sure. Whenever many customization options have to be added I see a wasted opportunity of adding a single render fragment parameter

I've added my motivation.

This PR seems a bit superficial to me. It adds a second way of doing things which are already doable. Correct me if I am wrong.
So if I understand correctly, your main motivation is being able to set things for all tabs in the MudTabs vs having to set it in every tab individually? If so, an RF template of type RenderFragment<MudTabPanel> on MudTabs would also be a viable solution right? A render fragment solution would not only allow customizing icons but also allow to replace them with something else entirely.

@henon That sounds very right; I'm going to try this and will close this PR accordingly.


Conflicting error handling instructions

SendRequest and other functions describe error reporting by returning 0 and by throwing a CInternetException object. These two approaches can't both be true. If a CInternetException is thrown, there will be no return value.

Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ID: ab214754-643b-097b-820a-fb77b7e2c441
Version Independent ID: 54b4a4ad-614f-26ac-53da-eea07d7d750c
Content: CHttpFile Class
Content Source: docs/mfc/reference/chttpfile-class.md
Product: visual-cpp
Technology: cpp-mfc
GitHub Login: @TylerMSFT
Microsoft Alias: twhitney

Closing as part of backlog grooming. We have accrued more issues than our resources can manage.
Criteria for closing include severity of the issue, how broadly applicable it is, whether the issue enough information is provide to act on the issue, etc.
If you think this issue should not have been closed, reopen it with a comment explaining why.