HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleBoolean-0.2.4Haskell98

Data.Boolean

Some classes for generalized boolean operations.

In this design, for if-then-else, equality and inequality tests, the boolean type depends on the value type.

I also tried using a unary type constructor class. The class doesn't work for regular booleans, so generality is lost. Also, we'd probably have to wire class constraints in like: (==*) :: Eq a => f Bool -> f a -> f a -> f a, which disallows situations needing additional constraints, e.g., Show.

Starting with 0.1.0, this package uses type families. Up to version 0.0.2, it used MPTCs with functional dependencies. My thanks to Andy Gill for suggesting & helping with the change.

  • 4 classes
  • 8 values
  • PackageBoolean-0.2.4
  • Exports13
  • LanguageHaskell98
  • LicenceBSD-3-Clause
  • SourceBoolean.hs
classclass Boolean b where
#

Generalized boolean class

Methods

Instances2Boolean
  • Boolean BoolDefined in Boolean-0.2.4 · Data.Boolean
  • Boolean bool => Boolean (z -> bool)Defined in Boolean-0.2.4 · Data.Boolean
familytype family BooleanOf a
#

BooleanOf computed the boolean analog of a specific type.

Instances11BooleanOf, …
classclass Boolean (BooleanOf a) => IfB a where
#

Types with conditionals

Methods

Instances11IfB, …
valueboolean :: (IfB a, bool ~ BooleanOf a) => a -> a -> bool -> a
#

Expression-lifted conditional with condition last

classclass Boolean (BooleanOf a) => EqB a where
#

Types with equality. Minimum definition: (==*).

Methods

Instances7EqB, …
  • EqB IntegerDefined in Boolean-0.2.4 · Data.Boolean
  • EqB BoolDefined in Boolean-0.2.4 · Data.Boolean
  • EqB CharDefined in Boolean-0.2.4 · Data.Boolean
  • EqB DoubleDefined in Boolean-0.2.4 · Data.Boolean
  • EqB FloatDefined in Boolean-0.2.4 · Data.Boolean
  • EqB IntDefined in Boolean-0.2.4 · Data.Boolean
  • EqB a => EqB (z -> a)Defined in Boolean-0.2.4 · Data.Boolean
classclass Boolean (BooleanOf a) => OrdB a where
#

Types with inequality. Minimum definition: (<*).

Methods

Instances7OrdB, …
  • OrdB IntegerDefined in Boolean-0.2.4 · Data.Boolean
  • OrdB BoolDefined in Boolean-0.2.4 · Data.Boolean
  • OrdB CharDefined in Boolean-0.2.4 · Data.Boolean
  • OrdB DoubleDefined in Boolean-0.2.4 · Data.Boolean
  • OrdB FloatDefined in Boolean-0.2.4 · Data.Boolean
  • OrdB IntDefined in Boolean-0.2.4 · Data.Boolean
  • OrdB a => OrdB (z -> a)Defined in Boolean-0.2.4 · Data.Boolean
valueguardedB :: (IfB b, bool ~ BooleanOf b) => bool -> [(bool, b)] -> b -> b
#

A generalized replacement for guards and chained ifs.

valuecaseB :: (IfB b, bool ~ BooleanOf b) => a -> [(a -> bool, b)] -> b -> b
#

A generalized version of a case like control structure.