Skip to content

Instantly share code, notes, and snippets.

@mbbx6spp
Last active October 20, 2024 14:35
Show Gist options
  • 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://www.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