Created
December 13, 2016 09:24
-
-
Save aratama/fa1c2b51753c0dd15ff162b36b9bd48d to your computer and use it in GitHub Desktop.
Type level boolean values
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 (Unit) | |
import Control.Monad.Eff (Eff) | |
import Control.Monad.Eff.Console (CONSOLE, log) | |
import Data.Symbol (SProxy(SProxy), reflectSymbol) | |
data True | |
data False | |
class Show a (b :: Symbol) | a -> b | |
instance showTrue :: Show True "True" | |
instance showFalse :: Show False "False" | |
class Not a b | a -> b | |
instance notTrue :: Not True False | |
instance notFalse :: Not False True | |
class Xor a b c | a b -> c | |
instance xorTT :: Xor True True False | |
instance xorFT :: Xor False True True | |
instance xorTF :: Xor True False True | |
instance xorFF :: Xor False False False | |
foo :: forall a. Show True a => SProxy a | |
foo = SProxy | |
bar :: forall a b. (Not True a, Show a b) => SProxy b | |
bar = SProxy | |
xor :: forall a b c. (Xor True False a, Not a b, Show b c) => SProxy c | |
xor = SProxy | |
main :: forall e. Eff (console :: CONSOLE | e) Unit | |
main = log (reflectSymbol xor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment