Created
October 31, 2021 02:23
-
-
Save pete-murphy/3f6da7f86beebe5b35e07a527cb5124b to your computer and use it in GitHub Desktop.
Simple ADT example
This file contains hidden or 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 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