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
// requires TypeScript 2.1 or higher | |
export abstract class Lens<T, U> { | |
abstract get: (obj: T) => U; | |
abstract set: (value: U) => (obj: T) => T; | |
then = <V>(lens: Lens<U, V>) => new ComposedLens(this, lens); | |
thenKey = <L extends keyof U>(key: L): Lens<T, U[L]> => this.then(new ObjectLens<U, L>(key)); | |
modify = (f: (value: U) => U) => (obj: T) => this.set(f(this.get(obj)))(obj); | |
} | |
export class IdLens<T> extends Lens<T, 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
yv66vgADAC0AEwwAEAASAQAWKFtMamF2YS9sYW5nL1N0cmluZzspVgEADEhlbGxvIFdvcmxkIQcACwgAAwcADgEABENvZGUBAARtYWluCQAGAAEMAAwAEQEAE2phdmEvaW8vUHJpbnRTdHJlYW0BAAdwcmludGxuBwAHAQAQamF2YS9sYW5nL1N5c3RlbQoABAAKAQADb3V0AQAVKExqYXZhL2xhbmcvU3RyaW5nOylWAQAVTGphdmEvaW8vUHJpbnRTdHJlYW07ACEADQAEAAAAAAABAAkACAACAAEABwAAABUAAgABAAAACbIACRIFtgAPsQAAAAAAAA== |
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
:- module ml. | |
:- interface. | |
:- import_module io. | |
:- pred main(io::di, io::uo) is cc_multi. | |
:- implementation. | |
:- import_module bool, int, string, list, pair, assoc_list, lex, regex. | |
main(!IO) :- | |
Lexer = lex.init(lexemes, lex.read_from_stdin, ignore(space)), | |
State0 = lex.start(Lexer, !.IO), |