Name: Anonymous 2014-02-19 0:40
{-# LANGUAGE TypeFamilies, RebindableSyntax #-}
import Prelude
class IfThenElse a where
type ThenT a b
type ThenT a b = b
type ElseT a b
type ElseT a b = b
ifThenElse :: a -> ThenT a b -> ElseT a b -> b
instance IfThenElse Bool where
ifThenElse True x _ = x
ifThenElse False _ y = y
instance IfThenElse (Maybe a) where
type ThenT (Maybe a) b = a -> b
type ElseT (Maybe a) b = b
ifThenElse (Just a) f _ = f a
ifThenElse Nothing _ b = b