raw-feldspar-0.1: Resource-Aware Feldspar

Safe HaskellNone
LanguageHaskell2010

Feldspar.Data.Validated

Description

Validated values

Validated is similar to Option, with the difference that Validated does not guarantee that invalid values are not evaluated. Therefore, Validated should not be used to guard operations from illegal use (e.g. array bounds checking).

Still, the operations try to defer evaluation of invalid values as much as possible.

Synopsis

Documentation

data Validated a Source #

A value that can be valid or invalid

Constructors

Validated (Data Bool) a 

Instances

Monad Validated Source # 

Methods

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

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

return :: a -> Validated a #

fail :: String -> Validated a #

Functor Validated Source # 

Methods

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

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

Applicative Validated Source # 

Methods

pure :: a -> Validated a #

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

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

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

Syntax a => Syntactic (Validated a) Source # 

Associated Types

type Domain (Validated a) :: * -> * #

type Internal (Validated a) :: * #

Forcible a => Forcible (Validated a) Source #

toValue will force the value even if it's invalid

Associated Types

type ValueRep (Validated a) :: * Source #

type Internal (Validated a) Source # 
type Domain (Validated a) Source # 
type ValueRep (Validated a) Source # 

validWhen :: Data Bool -> a -> Validated a Source #

Create a validated value. Note that the value may get evaluated even if the condition is false.

invalid :: Syntax a => Validated a Source #

Invalid value

validated Source #

Arguments

:: Syntax b 
=> b

Invalid case

-> (a -> b)

Valid case

-> Validated a 
-> b 

Deconstruct an Validated value

caseValidated Source #

Arguments

:: Syntax b 
=> Validated a 
-> b

Invalid case

-> (a -> b)

Valid case

-> b 

Deconstruct an Validated value

fromValidated Source #

Arguments

:: Syntax a 
=> Validated a 
-> a

Value to return in case the first arg. is invalid

-> a 

validatedM Source #

Arguments

:: MonadComp m 
=> m ()

Invalid case

-> (a -> m ())

Valid case

-> Validated a 
-> m () 

Deconstruct an Validated value

caseValidatedM Source #

Arguments

:: MonadComp m 
=> Validated a 
-> m ()

Invalid case

-> (a -> m ())

Valid case

-> m () 

Deconstruct an Validated value