packages feed

MicroHs-0.17.4.0: lib/Data/Ord/Class.hs

module Data.Ord.Class(Ord(..)) where
import qualified Prelude()              -- do not import Prelude
import Data.Bool_Type
import Data.Eq
import Data.Ordering_Type
import {-# SOURCE #-} Data.Typeable

infix 4 <,<=,>,>=

class Eq a => Ord a where
  compare :: a -> a -> Ordering
  (<) :: a -> a -> Bool
  (<=) :: a -> a -> Bool
  (>) :: a -> a -> Bool
  (>=) :: a -> a -> Bool
  max :: a -> a -> a
  min :: a -> a -> a

  compare x y = if x == y then EQ
                else if x <= y then LT
                else GT

  x <= y = case compare x y of { GT -> False; _ -> True }
  x >= y = y <= x
  x > y = if x <= y then False else True
  x < y = if y <= x then False else True

  min x y = if x <= y then x else y
  max x y = if x <= y then y else x