This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uses 'flyd' stream micro-library | |
type Stream = (_: number) => Stream // this life is a simplification | |
interface Model { | |
value: number | |
} | |
interface Actions { | |
increment: () => void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ======================================================================= | |
// Lenses | |
// ======================================================================= | |
type Setter<A, B extends keyof A> = Func2<A, A[B], A[B]> | |
type Getter<A, B extends keyof A> = Func<A, A[B]> | |
type Property<A, B extends keyof A> = B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"$id": "http://json-schema.org/draft-07/schema#", | |
"title": "Core schema meta-schema", | |
"definitions": { | |
"schemaArray": { | |
"type": "array", | |
"minItems": 1, | |
"items": { "$ref": "#" } | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Don't know why but this seems very impressive to me | |
type Func<A, B> = (_: A) => B | |
class Value<A> { | |
constructor(private _content: A ) { } | |
static of = <A>(data: A): Value<A> => new Value(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Entry { | |
value: string | |
label: string | |
} | |
type Dictionary = Entry[] | |
const dictionary: Dictionary = [ | |
{ value: 'primeiro', label: '1 - Primeiro' }, | |
{ value: 'segundo', label: '2 - Segundo' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A 100% type-safe solution to compose functions in typescript | |
// tested in TS 3.5.1 | |
type Func<A, B> = (_: A) => B | |
class ComposedFn<A, B> { | |
constructor(private f: Func<A, B>) { } | |
static of = <A,B>(fn: Func<A, B>): ComposedFn<A, B> => | |
new ComposedFn(fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ============================================================ | |
// Sample code: | |
// Modeling of parametrized Messages and a Generic Dispatcher | |
// | |
// Author: @fvilante | |
// ============================================================ | |
// Messages (or events, or actions...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ============================================== | |
// PROPOSAL OF SOLUTION | |
// ============================================== | |
// ================================ | |
// Emulate nominal type-system | |
// ================================ | |
type Kind<K> = { kind: K } | |
type Value<T> = { value: T } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Demonstration of Core Concepts | |
// Event Source Reducer functional style and typesafe | |
// ========================= | |
// Lib Event Source | |
// ========================= | |
type UserDocument = object | |
type State = ReadonlyArray<object> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mapObjIndexed } from 'ramda' | |
type PropMorphism | |
<TKeyValue, TContext extends object, TKeyName, TResult> = | |
(value: TKeyValue, context: TContext, keyname: TKeyName) => | |
TResult | |
/** | |
* Use HasExactlySameKeys if you want to assure to procced |