raw-feldspar-0.4.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

Instances details
Monad Validated Source # 
Instance details

Defined in Feldspar.Data.Validated

Methods

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

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

return :: a -> Validated a #

Functor Validated Source # 
Instance details

Defined in Feldspar.Data.Validated

Methods

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

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

Applicative Validated Source # 
Instance details

Defined in Feldspar.Data.Validated

Methods

pure :: a -> Validated a #

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

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

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

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

Syntax a => Syntactic (Validated a) Source # 
Instance details

Defined in Feldspar.Data.Validated

Associated Types

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

type Internal (Validated a) #

Forcible a => Forcible (Validated a) Source #

toValue will force the value even if it's invalid

Instance details

Defined in Feldspar.Data.Storable

Associated Types

type ValueRep (Validated a) Source #

type Internal (Validated a) Source # 
Instance details

Defined in Feldspar.Data.Validated

type Domain (Validated a) Source # 
Instance details

Defined in Feldspar.Data.Validated

type ValueRep (Validated a) Source # 
Instance details

Defined in Feldspar.Data.Storable

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