{-# LANGUAGE TypeFamilies, EmptyDataDecls #-}

{- |

Module      :  Type.Booleans
Copyright   :  (c) The University of Kansas 2011
License     :  BSD3

Maintainer  :  nicolas.frisby@gmail.com
Stability   :  experimental
Portability :  see LANGUAGE pragmas (... GHC)

Type-level booleans with very basic operations.

-}
module Type.Booleans where


data True
data False

type family If b x y
type instance If True  x y = x
type instance If False x y = y

type family And b1 b2
type instance And True  b = b
type instance And False b = False 

type family Or b1 b2
type instance Or True  b = True
type instance Or False b = b 

type family Not b
type instance Not True = False
type instance Not False = True

type Nand b1 b2 = Not (And b1 b2)
type Nor b1 b2 = Not (Or b1 b2)

type family Xor b1 b2
type instance Xor True False = True
type instance Xor False True = True
type instance Xor False False = False
type instance Xor True True = False

type family Beq b1 b2
type instance Beq True True = True
type instance Beq False False  = True
type instance Beq True False = True
type instance Beq False True = True