Skip to content

Instantly share code, notes, and snippets.

@pete-murphy
Created October 31, 2021 02:23
Show Gist options
  • Save pete-murphy/3f6da7f86beebe5b35e07a527cb5124b to your computer and use it in GitHub Desktop.
Save pete-murphy/3f6da7f86beebe5b35e07a527cb5124b to your computer and use it in GitHub Desktop.
Simple ADT example
module Main where
import Prelude
import Effect (Effect)
import Effect.Console as Console
import TryPureScript (render, withConsole)
data SchoolPerson = Teacher | Director | Student String
greeting :: SchoolPerson -> String
greeting = case _ of
Teacher -> "Hey Professor!"
Director -> "Hello Director."
Student "Richard" -> "Still here Ricky?"
Student anyOtherName -> "Hey, " <> anyOtherName <> "."
main :: Effect Unit
main = render =<< withConsole do
Console.logShow (greeting (Student "Richard"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment