-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Handle Boolean values generatically.
--
-- This package provides various functions and classes for dealing with
-- things which are like Boolean values. It also defines a few useful
-- instances. The main benefit is the ability to use the usual
-- &&, etc. operators without having to invent new
-- operator names for every kind of Bool-like thing.
@package AC-Boolean
@version 1.0.0
-- | Type classes (and instances) for things that are like Booleans.
--
-- The names of methods in Boolean clash with the standard
-- Prelude, so you probably want to inport the Prelude hiding these three
-- names (since the class methods do the same thing, but with more
-- general type signatures).
--
-- An interesting consequence of the Boolean instance for monads
-- is that Maybe Bool is a Boolean. You can use this
-- to implement 3-value logic ("true", "false" and "other"), with
-- Nothing implementing "other". Any logical operations yield
-- Nothing unless all arguments are Just something. (This
-- is usually the behaviour you want.)
module Data.Boolean
-- | Typeclass for things that have true and false values.
--
-- Instances:
--
--
-- - Normal Bool values (obviously).
-- - Any function that yields a BoolValue as its result. (For
-- example, true is just a constant function that always returns a
-- truth value, regardless of its input.)
-- - Any monadic action that yields a BoolValue as its result.
-- (This is just return applied to the appropriate
-- BoolValue.)
--
class BoolValue b
true :: (BoolValue b) => b
false :: (BoolValue b) => b
-- | Convert a Bool value to the appropriate BoolValue.
lift_bool :: (BoolValue b) => Bool -> b
-- | Typeclass for things that support Boolean operators.
--
-- Instances:
--
--
-- - Normal Bool values (obviously).
-- - Any function that returns a Boolean. (The result is a new
-- function that runs the old function(s) and applies the appropriate
-- operator to the result(s).)
-- - Any monadic action that returns a Boolean. (Again, the
-- result is a new action that runs the existing action(s) and applies
-- the appropriate operator to the result(s).)
--
class Boolean b
(&&) :: (Boolean b) => b -> b -> b
(||) :: (Boolean b) => b -> b -> b
not :: (Boolean b) => b -> b
xor :: (Boolean b) => b -> b -> b
instance (Monad m, Boolean b) => Boolean (m b)
instance (Boolean b) => Boolean (x -> b)
instance Boolean Bool
instance (Monad m, BoolValue b) => BoolValue (m b)
instance (BoolValue b) => BoolValue (x -> b)
instance BoolValue Bool