Created
February 25, 2015 17:48
-
-
Save michaelficarra/236244fb1afa30c8172f to your computer and use it in GitHub Desktop.
phantom types using rows in PureScript; needs DataKinds to achieve full awesome
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 | |
--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