Last active
September 19, 2018 04:47
-
-
Save fragamus/588c2ccf7f04f4897cf62ed4842ed1eb to your computer and use it in GitHub Desktop.
Existential
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
{-# LANGUAGE GADTs #-} | |
import Data.Some | |
data ZeroOneTwo a where | |
Zero :: ZeroOneTwo () | |
One :: Int -> ZeroOneTwo Int | |
Two :: (Int,Int) -> ZeroOneTwo Int | |
getSome :: Some ZeroOneTwo | |
getSome = This $ Two (3,10) | |
useSome :: Some ZeroOneTwo -> Int | |
useSome (This Zero) = 5 | |
useSome (This (One (x))) = 6 | |
useSome (This (Two (x,y))) = x+y | |
main = do | |
let c = getSome | |
let d = useSome c | |
print d | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment