Last active
October 20, 2024 14:35
-
-
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/
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 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