Created
February 10, 2016 05:22
-
-
Save akhileshs/26d23e353b17d639f186 to your computer and use it in GitHub Desktop.
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
data Message = PlainText String | Encrypted String | |
send :: Message -> Recipient -> IO () | |
send (Encrypted m) recipient = some magic with m | |
send (PlainText _) _ = undefined | |
data Maybe a = Just a | Nothing | |
-- movin' to phantom types | |
data Message a = Message String | |
data Encrypted | |
data PlainText | |
-- change send now | |
send :: Message Encrypted -> Recipient -> IO () | |
encrypt :: Message PlainText -> Message Encrypted | |
decrypt :: Message Encrypted -> Message PlainText | |
newMessage :: String -> Message PlainText | |
newMessage s = Message s | |
-- this will get rejected by the type-checker | |
-- send (newMessage "hello!") "abc@xyz.com" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment