Skip to content

Instantly share code, notes, and snippets.

@mbbx6spp
Last active August 11, 2020 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbbx6spp/b4d9dc9fba5339ac11ef6334cab1f066 to your computer and use it in GitHub Desktop.
Save mbbx6spp/b4d9dc9fba5339ac11ef6334cab1f066 to your computer and use it in GitHub Desktop.
Accompanying PureScript demonstration of native ADTs for the 'Algebraic Data Types in PureScript': https://susanpotter.net/software/algebraic-data-types-in-typescript/
module Main (main) where
import Data.Unit (Unit)
import Data.Maybe (Maybe (..))
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = log "hello world"
--- play with ADTs below
data Foo a
= Bar { bar :: String }
| Baz { baz :: Int }
| Qux { qux :: Boolean, quux :: Maybe a }
foo0 = Bar { bar : "wowser" }
foo1 = Baz { baz : 3000 }
foo2 = Qux { qux : true, quux : Nothing }
data Currency = USD | CHF | EUR | JPY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment