{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds #-}

{- |

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
  (Compare, OrdCase, IsEQ, IsLT, IsGT) where

-- | Type-level comparison.
type family Compare (l :: k) (r :: k) :: Ordering

-- | @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 :: Ordering) (a :: k) (b :: k) (c :: k) :: k
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