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
// getEmptyPlate :: IxBurgerBuilder Ready EmptyPlate BurgerSpec | |
// getEmptyPlate = IxBurgerBuilder mempty | |
const getEmptyPlate = new IxBurgerBuilder<Ready, EmptyPlate, BurgerSpec>([]); | |
// addIngredient :: forall i o. String -> BurgerSpec -> IxBurgerBuilder i o (BurgerSpec) | |
// addIngredient x xs = IxBurgerBuilder $ Ingredient x : xs | |
const addIngredient = <I, O>(s: string) => (spec: BurgerSpec) => new IxBurgerBuilder<I ,O, BurgerSpec>(spec.concat([s])); | |
// -- ADDING THE BUN | |
// placeEmptyBun :: BurgerSpec -> IxBurgerBuilder EmptyPlate BottomBunOn BurgerSpec |
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 { Functor3 } from 'fp-ts/lib/Functor' | |
import { IxMonad3 } from 'fp-ts/lib/IxMonad'; | |
declare module 'fp-ts/lib/HKT' { | |
// IxBurgerBuilder :: * -> * -> * -> * | |
interface URI2HKT3<U, L, A> { | |
IxBurgerBuilder: IxBurgerBuilder<U, L, A> | |
} | |
} |
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
// data Ready | |
// data EmptyPlate | |
// data BottomBunOn | |
// data PattyOn | |
// data CheeseOn | |
// data OnionOn | |
// data LettuceOn | |
// data TomatoOn | |
// data PicklesOn | |
// data TopBunOn |
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 { log } from 'fp-ts/lib/Console' | |
import { Type, URIS } from 'fp-ts/lib/HKT' | |
import { none, Option, some } from 'fp-ts/lib/Option' | |
import { randomInt } from 'fp-ts/lib/Random' | |
import { fromIO, Task, task, URI as TaskURI } from 'fp-ts/lib/Task' | |
import { createInterface } from 'readline' | |
// | |
// helpers | |
// |
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 { log } from 'fp-ts/lib/Console' | |
import { none, Option, some } from 'fp-ts/lib/Option' | |
import { randomInt } from 'fp-ts/lib/Random' | |
import { fromIO, Task, task } from 'fp-ts/lib/Task' | |
import { createInterface } from 'readline' | |
// | |
// helpers | |
// |
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
// Types: | |
type Just<T> = { Just: T } | |
type Nothing = {} | |
type Maybe<T> = Just<T> | Nothing | |
type Left<L> = { Left: L } | |
type Right<R> = { Right: R } | |
type Either<L, R> = Left<L> | Right<R> | |
// For convenience: |
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
// in response to https://twitter.com/arntzenius/status/1022076441603829760 | |
// types A,B ∷= base | A → B | |
// terms M ∷= E | λx.M | |
// exprs E ∷= x | E M | (M : A) | |
type Type = "Base" | {lhs: Type, tag: "->", rhs: Type}; | |
type Var = string; | |
type Term = Expr | {tag: "Lam", varname: Var, body: Term}; | |
type Expr = Var | {tag: "App", fn: Expr, arg: Term} | {term: Term, tag: ":", tp: Type}; |
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
const Day = ({ get, left, right }) => { | |
const map = f => Day ({ | |
get: f (extract()), | |
left, right | |
}) | |
const extend = f => | |
Day ({ | |
get: (left, right) => f (Day ({ get, left, right })), |
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
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
module Main where | |
import Unsafe.Coerce |
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
{-# LANGUAGE ConstraintKinds, DataKinds, DeriveGeneric, DerivingVia #-} | |
{-# LANGUAGE ExplicitNamespaces, FlexibleContexts, FlexibleInstances #-} | |
{-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds, ScopedTypeVariables, StandaloneDeriving #-} | |
{-# LANGUAGE TypeApplications, TypeFamilies, TypeInType, TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# OPTIONS_GHC -Wall #-} | |
module Data.Aeson.Generic.DerivingVia | |
( StrFun(..), Setting(..), SumEncoding'(..), DefaultOptions, WithOptions(..) | |
, -- Utility type synonyms to save ticks (') before promoted data constructors |