Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Created February 25, 2015 17:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelficarra/236244fb1afa30c8172f to your computer and use it in GitHub Desktop.
Save michaelficarra/236244fb1afa30c8172f to your computer and use it in GitHub Desktop.
phantom types using rows in PureScript; needs DataKinds to achieve full awesome
module Main where
--data Language = English | Spanish
--data Censored = Censored | NotCensored
--data Encoding = Plain | EncodingA | EncodingB
data English
data Spanish
data Censored
data NotCensored
data Plain
data EncodingA
data EncodingB
data Message (constraints :: # *) = Message String
--data Message (language :: Language, censored :: Censored, encoding :: Encoding) = Message String
mkMessage :: String -> Message (language :: English, censored :: NotCensored, encoding :: Plain)
mkMessage a = Message a
sendMessage :: forall msgProps. Message (encoding :: EncodingA | msgProps) -> Unit
sendMessage a = unit
--sentMessage = sendMessage (mkMessage "test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment