{-# LANGUAGE TypeFamilies, EmptyDataDecls #-}

{- |

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

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

Type-level comparison operator, its result \"kind\", and that kind's case

module Type.Ord.Base
  (module Type.Booleans, Compare, LT, EQ, GT, OrdCase, IsEQ, IsLT, IsGT) where

import Type.Booleans (True, False)

-- | Type-level comparison.
type family Compare l r

data LT; data EQ; data GT

-- | @OrdCase x a b c@ reduces to @a@, @b@, or @c@, if @x@ is @LT@, @EQ@, or
-- @GT@, respectively.
type OrdCase x a b c = OrdCase_ x a b c
type family OrdCase_ x a b c
type instance OrdCase_ LT a b c = a
type instance OrdCase_ EQ a b c = b
type instance OrdCase_ GT a b c = c

type IsEQ t = OrdCase t False True False
type IsLT t = OrdCase t True False False
type IsGT t = OrdCase t False False True