oalg-base-1.1.4.0: Algebraic structures on oriented entities and limits as a tool kit to solve algebraic problems.
Copyright(c) Erich Gut
LicenseBSD3
Maintainerzerich.gut@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

OAlg.Control.Solver

Description

A monad to express solving algebraic problems which may fail.

Note To express algebraic unsolvable - e.g determine the multiplicative inverse of 0 - one should only use the failure mechanism from this module (see examples in solvable).

Synopsis

Result Type For Solving Algebraic Problems

data Solver x Source #

monad to solve algebraic problems which may fail because it is not solvable or ...

Instances

Instances details
Applicative Solver Source # 
Instance details

Defined in OAlg.Control.Solver

Methods

pure :: a -> Solver a #

(<*>) :: Solver (a -> b) -> Solver a -> Solver b #

liftA2 :: (a -> b -> c) -> Solver a -> Solver b -> Solver c #

(*>) :: Solver a -> Solver b -> Solver b #

(<*) :: Solver a -> Solver b -> Solver a #

Functor Solver Source # 
Instance details

Defined in OAlg.Control.Solver

Methods

fmap :: (a -> b) -> Solver a -> Solver b #

(<$) :: a -> Solver b -> Solver a #

Monad Solver Source # 
Instance details

Defined in OAlg.Control.Solver

Methods

(>>=) :: Solver a -> (a -> Solver b) -> Solver b #

(>>) :: Solver a -> Solver b -> Solver b #

return :: a -> Solver a #

Show x => Show (Solver x) Source # 
Instance details

Defined in OAlg.Control.Solver

Methods

showsPrec :: Int -> Solver x -> ShowS #

show :: Solver x -> String #

showList :: [Solver x] -> ShowS #

failure :: Exception e => e -> Solver x Source #

throwing exception in to Solver to express unsolvable.

handle :: Exception e => Solver x -> (e -> Solver x) -> Solver x Source #

handling exception.

Note Only exceptions expressed via the failure mechanism can be handled by handle!

solve :: Solver x -> x Source #

extracting the solution from the solver. If during solving an exception e occurs, then e will be thrown via the regular throw mechanism of Exception.

Note solve extracts the solution lazy!

solvable :: Solver r -> Bool Source #

checks for solvability of a algebraic problem represented be a solver s (see also solve).