{-# OPTIONS_GHC -XNoImplicitPrelude #-}{-# OPTIONS_HADDOCK hide #-}------------------------------------------------------------------------------- |-- Module : GHC.Classes-- Copyright : (c) The University of Glasgow, 1992-2002-- License : see libraries/base/LICENSE---- Maintainer : cvs-ghc@haskell.org-- Stability : internal-- Portability : non-portable (GHC extensions)---- Basic classes.-------------------------------------------------------------------------------moduleGHC.ClasseswhereimportGHC.BoolimportGHC.Orderinginfix4==,/=,<,<=,>=,>infixr3&&infixr2||default()-- Double isn't available yet-- | The 'Eq' class defines equality ('==') and inequality ('/=').-- All the basic datatypes exported by the "Prelude" are instances of 'Eq',-- and 'Eq' may be derived for any datatype whose constituents are also-- instances of 'Eq'.---- Minimal complete definition: either '==' or '/='.--classEqawhere(==),(/=)::a->a->Boolx/=y=not(x==y)x==y=not(x/=y)-- | The 'Ord' class is used for totally ordered datatypes.---- Instances of 'Ord' can be derived for any user-defined-- datatype whose constituent types are in 'Ord'. The declared order-- of the constructors in the data declaration determines the ordering-- in derived 'Ord' instances. The 'Ordering' datatype allows a single-- comparison to determine the precise ordering of two objects.---- Minimal complete definition: either 'compare' or '<='.-- Using 'compare' can be more efficient for complex types.--class(Eqa)=>Ordawherecompare::a->a->Ordering(<),(<=),(>),(>=)::a->a->Boolmax,min::a->a->acomparexy=ifx==ythenEQ-- NB: must be '<=' not '<' to validate the-- above claim about the minimal things that-- can be defined for an instance of Ord:elseifx<=ythenLTelseGTx<y=casecomparexyof{LT->True;_->False}x<=y=casecomparexyof{GT->False;_->True}x>y=casecomparexyof{GT->True;_->False}x>=y=casecomparexyof{LT->False;_->True}-- These two default methods use '<=' rather than 'compare'-- because the latter is often more expensivemaxxy=ifx<=ythenyelsexminxy=ifx<=ythenxelsey-- OK, so they're technically not part of a class...:-- Boolean functions-- | Boolean \"and\"(&&)::Bool->Bool->BoolTrue&&x=xFalse&&_=False-- | Boolean \"or\"(||)::Bool->Bool->BoolTrue||_=TrueFalse||x=x-- | Boolean \"not\"not::Bool->BoolnotTrue=FalsenotFalse=True