dino-0.1: A convenient tagless EDSL

Safe HaskellNone
LanguageHaskell2010

Dino.Expression

Contents

Description

General tagless expressions

Synopsis

Expression classes and constructs

Constants

class ConstExp e where Source #

Constant expressions

The default implementation is for Applicative interpretations.

Minimal complete definition

Nothing

Methods

lit :: DinoType a => a -> e a Source #

Make a Dino literal from a Haskell value

lit :: Applicative e => a -> e a Source #

Make a Dino literal from a Haskell value

Instances
ConstExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> Maybe a Source #

ConstExp Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> Identity a Source #

ConstExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> DinoTypeRep a Source #

ConstExp Reified Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> Reified a Source #

ConstExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> Either e a Source #

ConstExp e => ConstExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> CollectAssertions e a Source #

ConstExp e => ConstExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> AssertViaMonadThrow e a Source #

ConstExp e => ConstExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> AssertViaMonadError e a Source #

Applicative e => ConstExp (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> EvalEnv e a Source #

ConstExp e => ConstExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> Intensional e a Source #

Monoid e => ConstExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> Fold e a Source #

Monad m => ConstExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> ExceptT e m a Source #

(Monoid t, Applicative m) => ConstExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> WriterT t m a Source #

ConstExp e => ConstExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

lit :: DinoType a => a -> Exp e a Source #

(ConstExp e1, ConstExp e2) => ConstExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> (e1 :×: e2) a Source #

Applicative m => ConstExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

lit :: DinoType a => a -> ReaderT env m a Source #

text :: ConstExp e => Text -> e Text Source #

Constant text expression

With OverloadedStrings enabled, text literals can be written simply as "...".

Numeric expressions

class NumExp e where Source #

Numeric expressions

The default implementations are for Applicative interpretations.

Minimal complete definition

Nothing

Methods

add :: Num a => e a -> e a -> e a Source #

sub :: Num a => e a -> e a -> e a Source #

mul :: Num a => e a -> e a -> e a Source #

absE :: Num a => e a -> e a Source #

signE :: Num a => e a -> e a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => e a -> e b Source #

Convert an integer to any numeric type

floor :: (RealFrac a, DinoType b, Integral b) => e a -> e b Source #

floor x returns the greatest integer not greater than x

truncate :: (RealFrac a, DinoType b, Integral b) => e a -> e b Source #

truncate x returns the integer nearest x between zero and x

roundN :: RealFrac a => Int -> e a -> e a Source #

Round to the specified number of decimals

add :: (Applicative e, Num a) => e a -> e a -> e a Source #

sub :: (Applicative e, Num a) => e a -> e a -> e a Source #

mul :: (Applicative e, Num a) => e a -> e a -> e a Source #

absE :: (Applicative e, Num a) => e a -> e a Source #

signE :: (Applicative e, Num a) => e a -> e a Source #

fromIntegral :: (Applicative e, Integral a, Num b) => e a -> e b Source #

Convert an integer to any numeric type

floor :: (Applicative e, RealFrac a, Integral b) => e a -> e b Source #

floor x returns the greatest integer not greater than x

truncate :: (Applicative e, RealFrac a, Integral b) => e a -> e b Source #

truncate x returns the integer nearest x between zero and x

roundN :: (Applicative e, RealFrac a) => Int -> e a -> e a Source #

Round to the specified number of decimals

Instances
NumExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => Maybe a -> Maybe a -> Maybe a Source #

sub :: Num a => Maybe a -> Maybe a -> Maybe a Source #

mul :: Num a => Maybe a -> Maybe a -> Maybe a Source #

absE :: Num a => Maybe a -> Maybe a Source #

signE :: Num a => Maybe a -> Maybe a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => Maybe a -> Maybe b Source #

floor :: (RealFrac a, DinoType b, Integral b) => Maybe a -> Maybe b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => Maybe a -> Maybe b Source #

roundN :: RealFrac a => Int -> Maybe a -> Maybe a Source #

NumExp Identity Source # 
Instance details

Defined in Dino.Interpretation

NumExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

NumExp Reified Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => Reified a -> Reified a -> Reified a Source #

sub :: Num a => Reified a -> Reified a -> Reified a Source #

mul :: Num a => Reified a -> Reified a -> Reified a Source #

absE :: Num a => Reified a -> Reified a Source #

signE :: Num a => Reified a -> Reified a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => Reified a -> Reified b Source #

floor :: (RealFrac a, DinoType b, Integral b) => Reified a -> Reified b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => Reified a -> Reified b Source #

roundN :: RealFrac a => Int -> Reified a -> Reified a Source #

NumExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => Either e a -> Either e a -> Either e a Source #

sub :: Num a => Either e a -> Either e a -> Either e a Source #

mul :: Num a => Either e a -> Either e a -> Either e a Source #

absE :: Num a => Either e a -> Either e a Source #

signE :: Num a => Either e a -> Either e a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => Either e a -> Either e b Source #

floor :: (RealFrac a, DinoType b, Integral b) => Either e a -> Either e b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => Either e a -> Either e b Source #

roundN :: RealFrac a => Int -> Either e a -> Either e a Source #

NumExp e => NumExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

NumExp e => NumExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

NumExp e => NumExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Applicative e => NumExp (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => EvalEnv e a -> EvalEnv e a -> EvalEnv e a Source #

sub :: Num a => EvalEnv e a -> EvalEnv e a -> EvalEnv e a Source #

mul :: Num a => EvalEnv e a -> EvalEnv e a -> EvalEnv e a Source #

absE :: Num a => EvalEnv e a -> EvalEnv e a Source #

signE :: Num a => EvalEnv e a -> EvalEnv e a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => EvalEnv e a -> EvalEnv e b Source #

floor :: (RealFrac a, DinoType b, Integral b) => EvalEnv e a -> EvalEnv e b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => EvalEnv e a -> EvalEnv e b Source #

roundN :: RealFrac a => Int -> EvalEnv e a -> EvalEnv e a Source #

NumExp e => NumExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Monoid e => NumExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => Fold e a -> Fold e a -> Fold e a Source #

sub :: Num a => Fold e a -> Fold e a -> Fold e a Source #

mul :: Num a => Fold e a -> Fold e a -> Fold e a Source #

absE :: Num a => Fold e a -> Fold e a Source #

signE :: Num a => Fold e a -> Fold e a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => Fold e a -> Fold e b Source #

floor :: (RealFrac a, DinoType b, Integral b) => Fold e a -> Fold e b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => Fold e a -> Fold e b Source #

roundN :: RealFrac a => Int -> Fold e a -> Fold e a Source #

Monad m => NumExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

sub :: Num a => ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

mul :: Num a => ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

absE :: Num a => ExceptT e m a -> ExceptT e m a Source #

signE :: Num a => ExceptT e m a -> ExceptT e m a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => ExceptT e m a -> ExceptT e m b Source #

floor :: (RealFrac a, DinoType b, Integral b) => ExceptT e m a -> ExceptT e m b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => ExceptT e m a -> ExceptT e m b Source #

roundN :: RealFrac a => Int -> ExceptT e m a -> ExceptT e m a Source #

(Monoid t, Applicative m) => NumExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => WriterT t m a -> WriterT t m a -> WriterT t m a Source #

sub :: Num a => WriterT t m a -> WriterT t m a -> WriterT t m a Source #

mul :: Num a => WriterT t m a -> WriterT t m a -> WriterT t m a Source #

absE :: Num a => WriterT t m a -> WriterT t m a Source #

signE :: Num a => WriterT t m a -> WriterT t m a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => WriterT t m a -> WriterT t m b Source #

floor :: (RealFrac a, DinoType b, Integral b) => WriterT t m a -> WriterT t m b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => WriterT t m a -> WriterT t m b Source #

roundN :: RealFrac a => Int -> WriterT t m a -> WriterT t m a Source #

NumExp e => NumExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

add :: Num a => Exp e a -> Exp e a -> Exp e a Source #

sub :: Num a => Exp e a -> Exp e a -> Exp e a Source #

mul :: Num a => Exp e a -> Exp e a -> Exp e a Source #

absE :: Num a => Exp e a -> Exp e a Source #

signE :: Num a => Exp e a -> Exp e a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => Exp e a -> Exp e b Source #

floor :: (RealFrac a, DinoType b, Integral b) => Exp e a -> Exp e b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => Exp e a -> Exp e b Source #

roundN :: RealFrac a => Int -> Exp e a -> Exp e a Source #

(NumExp e1, NumExp e2) => NumExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

sub :: Num a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

mul :: Num a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

absE :: Num a => (e1 :×: e2) a -> (e1 :×: e2) a Source #

signE :: Num a => (e1 :×: e2) a -> (e1 :×: e2) a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => (e1 :×: e2) a -> (e1 :×: e2) b Source #

floor :: (RealFrac a, DinoType b, Integral b) => (e1 :×: e2) a -> (e1 :×: e2) b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => (e1 :×: e2) a -> (e1 :×: e2) b Source #

roundN :: RealFrac a => Int -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

Applicative m => NumExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

add :: Num a => ReaderT env m a -> ReaderT env m a -> ReaderT env m a Source #

sub :: Num a => ReaderT env m a -> ReaderT env m a -> ReaderT env m a Source #

mul :: Num a => ReaderT env m a -> ReaderT env m a -> ReaderT env m a Source #

absE :: Num a => ReaderT env m a -> ReaderT env m a Source #

signE :: Num a => ReaderT env m a -> ReaderT env m a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => ReaderT env m a -> ReaderT env m b Source #

floor :: (RealFrac a, DinoType b, Integral b) => ReaderT env m a -> ReaderT env m b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => ReaderT env m a -> ReaderT env m b Source #

roundN :: RealFrac a => Int -> ReaderT env m a -> ReaderT env m a Source #

fromInt :: (NumExp e, DinoType a, Num a) => e Integer -> e a Source #

Convert an Integer to any numeric type

class FracExp e where Source #

Fractional expressions

The default implementation is for Applicative interpretations.

Minimal complete definition

Nothing

Methods

fdiv :: (Fractional a, Eq a) => e a -> e a -> e a Source #

Division

fdiv :: (Applicative e, Fractional a) => e a -> e a -> e a Source #

Division

Instances
FracExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => Maybe a -> Maybe a -> Maybe a Source #

FracExp Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => Identity a -> Identity a -> Identity a Source #

FracExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => DinoTypeRep a -> DinoTypeRep a -> DinoTypeRep a Source #

FracExp Reified Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => Reified a -> Reified a -> Reified a Source #

FracExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => Either e a -> Either e a -> Either e a Source #

FracExp e => FracExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

FracExp e => FracExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

FracExp e => FracExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Applicative e => FracExp (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => EvalEnv e a -> EvalEnv e a -> EvalEnv e a Source #

FracExp e => FracExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => Intensional e a -> Intensional e a -> Intensional e a Source #

Monoid e => FracExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => Fold e a -> Fold e a -> Fold e a Source #

Monad m => FracExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

(Monoid t, Applicative m) => FracExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => WriterT t m a -> WriterT t m a -> WriterT t m a Source #

FracExp e => FracExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

fdiv :: (Fractional a, Eq a) => Exp e a -> Exp e a -> Exp e a Source #

(FracExp e1, FracExp e2) => FracExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

Applicative m => FracExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

fdiv :: (Fractional a, Eq a) => ReaderT env m a -> ReaderT env m a -> ReaderT env m a Source #

(./) :: (ConstExp e, FracExp e, CompareExp e, CondExpFO e, DinoType a, Fractional a) => e a -> e a -> e a Source #

Division that returns 0 when the denominator is 0

Logic expressions

class LogicExp e where Source #

Logic expressions

The default implementations are for Applicative interpretations.

Minimal complete definition

Nothing

Methods

not :: e Bool -> e Bool Source #

conj :: e Bool -> e Bool -> e Bool Source #

disj :: e Bool -> e Bool -> e Bool Source #

xor :: e Bool -> e Bool -> e Bool Source #

not :: Applicative e => e Bool -> e Bool Source #

conj :: Applicative e => e Bool -> e Bool -> e Bool Source #

disj :: Applicative e => e Bool -> e Bool -> e Bool Source #

xor :: Applicative e => e Bool -> e Bool -> e Bool Source #

Instances
LogicExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

LogicExp Identity Source # 
Instance details

Defined in Dino.Interpretation

LogicExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

LogicExp Reified Source # 
Instance details

Defined in Dino.Interpretation

LogicExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

LogicExp e => LogicExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

LogicExp e => LogicExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

LogicExp e => LogicExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Applicative e => LogicExp (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

LogicExp e => LogicExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Monoid e => LogicExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

not :: Fold e Bool -> Fold e Bool Source #

conj :: Fold e Bool -> Fold e Bool -> Fold e Bool Source #

disj :: Fold e Bool -> Fold e Bool -> Fold e Bool Source #

xor :: Fold e Bool -> Fold e Bool -> Fold e Bool Source #

Monad m => LogicExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

not :: ExceptT e m Bool -> ExceptT e m Bool Source #

conj :: ExceptT e m Bool -> ExceptT e m Bool -> ExceptT e m Bool Source #

disj :: ExceptT e m Bool -> ExceptT e m Bool -> ExceptT e m Bool Source #

xor :: ExceptT e m Bool -> ExceptT e m Bool -> ExceptT e m Bool Source #

(Monoid t, Applicative m) => LogicExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

not :: WriterT t m Bool -> WriterT t m Bool Source #

conj :: WriterT t m Bool -> WriterT t m Bool -> WriterT t m Bool Source #

disj :: WriterT t m Bool -> WriterT t m Bool -> WriterT t m Bool Source #

xor :: WriterT t m Bool -> WriterT t m Bool -> WriterT t m Bool Source #

LogicExp e => LogicExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

not :: Exp e Bool -> Exp e Bool Source #

conj :: Exp e Bool -> Exp e Bool -> Exp e Bool Source #

disj :: Exp e Bool -> Exp e Bool -> Exp e Bool Source #

xor :: Exp e Bool -> Exp e Bool -> Exp e Bool Source #

(LogicExp e1, LogicExp e2) => LogicExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

not :: (e1 :×: e2) Bool -> (e1 :×: e2) Bool Source #

conj :: (e1 :×: e2) Bool -> (e1 :×: e2) Bool -> (e1 :×: e2) Bool Source #

disj :: (e1 :×: e2) Bool -> (e1 :×: e2) Bool -> (e1 :×: e2) Bool Source #

xor :: (e1 :×: e2) Bool -> (e1 :×: e2) Bool -> (e1 :×: e2) Bool Source #

Applicative m => LogicExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

not :: ReaderT env m Bool -> ReaderT env m Bool Source #

conj :: ReaderT env m Bool -> ReaderT env m Bool -> ReaderT env m Bool Source #

disj :: ReaderT env m Bool -> ReaderT env m Bool -> ReaderT env m Bool Source #

xor :: ReaderT env m Bool -> ReaderT env m Bool -> ReaderT env m Bool Source #

(&&) :: LogicExp e => e Bool -> e Bool -> e Bool infixr 3 Source #

(||) :: LogicExp e => e Bool -> e Bool -> e Bool infixr 2 Source #

Comparisons

class CompareExp e where Source #

Comparisons

The default implementations are for Applicative interpretations.

Minimal complete definition

Nothing

Methods

eq :: Eq a => e a -> e a -> e Bool Source #

neq :: Eq a => e a -> e a -> e Bool Source #

lt :: Ord a => e a -> e a -> e Bool Source #

gt :: Ord a => e a -> e a -> e Bool Source #

lte :: Ord a => e a -> e a -> e Bool Source #

gte :: Ord a => e a -> e a -> e Bool Source #

min :: Ord a => e a -> e a -> e a Source #

max :: Ord a => e a -> e a -> e a Source #

eq :: (Applicative e, Eq a) => e a -> e a -> e Bool Source #

neq :: (Applicative e, Eq a) => e a -> e a -> e Bool Source #

lt :: (Applicative e, Ord a) => e a -> e a -> e Bool Source #

gt :: (Applicative e, Ord a) => e a -> e a -> e Bool Source #

lte :: (Applicative e, Ord a) => e a -> e a -> e Bool Source #

gte :: (Applicative e, Ord a) => e a -> e a -> e Bool Source #

min :: (Applicative e, Ord a) => e a -> e a -> e a Source #

max :: (Applicative e, Ord a) => e a -> e a -> e a Source #

Instances
CompareExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => Maybe a -> Maybe a -> Maybe Bool Source #

neq :: Eq a => Maybe a -> Maybe a -> Maybe Bool Source #

lt :: Ord a => Maybe a -> Maybe a -> Maybe Bool Source #

gt :: Ord a => Maybe a -> Maybe a -> Maybe Bool Source #

lte :: Ord a => Maybe a -> Maybe a -> Maybe Bool Source #

gte :: Ord a => Maybe a -> Maybe a -> Maybe Bool Source #

min :: Ord a => Maybe a -> Maybe a -> Maybe a Source #

max :: Ord a => Maybe a -> Maybe a -> Maybe a Source #

CompareExp Identity Source # 
Instance details

Defined in Dino.Interpretation

CompareExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

CompareExp Reified Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => Reified a -> Reified a -> Reified Bool Source #

neq :: Eq a => Reified a -> Reified a -> Reified Bool Source #

lt :: Ord a => Reified a -> Reified a -> Reified Bool Source #

gt :: Ord a => Reified a -> Reified a -> Reified Bool Source #

lte :: Ord a => Reified a -> Reified a -> Reified Bool Source #

gte :: Ord a => Reified a -> Reified a -> Reified Bool Source #

min :: Ord a => Reified a -> Reified a -> Reified a Source #

max :: Ord a => Reified a -> Reified a -> Reified a Source #

CompareExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => Either e a -> Either e a -> Either e Bool Source #

neq :: Eq a => Either e a -> Either e a -> Either e Bool Source #

lt :: Ord a => Either e a -> Either e a -> Either e Bool Source #

gt :: Ord a => Either e a -> Either e a -> Either e Bool Source #

lte :: Ord a => Either e a -> Either e a -> Either e Bool Source #

gte :: Ord a => Either e a -> Either e a -> Either e Bool Source #

min :: Ord a => Either e a -> Either e a -> Either e a Source #

max :: Ord a => Either e a -> Either e a -> Either e a Source #

CompareExp e => CompareExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

CompareExp e => CompareExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

CompareExp e => CompareExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Applicative e => CompareExp (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => EvalEnv e a -> EvalEnv e a -> EvalEnv e Bool Source #

neq :: Eq a => EvalEnv e a -> EvalEnv e a -> EvalEnv e Bool Source #

lt :: Ord a => EvalEnv e a -> EvalEnv e a -> EvalEnv e Bool Source #

gt :: Ord a => EvalEnv e a -> EvalEnv e a -> EvalEnv e Bool Source #

lte :: Ord a => EvalEnv e a -> EvalEnv e a -> EvalEnv e Bool Source #

gte :: Ord a => EvalEnv e a -> EvalEnv e a -> EvalEnv e Bool Source #

min :: Ord a => EvalEnv e a -> EvalEnv e a -> EvalEnv e a Source #

max :: Ord a => EvalEnv e a -> EvalEnv e a -> EvalEnv e a Source #

CompareExp e => CompareExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Monoid e => CompareExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => Fold e a -> Fold e a -> Fold e Bool Source #

neq :: Eq a => Fold e a -> Fold e a -> Fold e Bool Source #

lt :: Ord a => Fold e a -> Fold e a -> Fold e Bool Source #

gt :: Ord a => Fold e a -> Fold e a -> Fold e Bool Source #

lte :: Ord a => Fold e a -> Fold e a -> Fold e Bool Source #

gte :: Ord a => Fold e a -> Fold e a -> Fold e Bool Source #

min :: Ord a => Fold e a -> Fold e a -> Fold e a Source #

max :: Ord a => Fold e a -> Fold e a -> Fold e a Source #

Monad m => CompareExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => ExceptT e m a -> ExceptT e m a -> ExceptT e m Bool Source #

neq :: Eq a => ExceptT e m a -> ExceptT e m a -> ExceptT e m Bool Source #

lt :: Ord a => ExceptT e m a -> ExceptT e m a -> ExceptT e m Bool Source #

gt :: Ord a => ExceptT e m a -> ExceptT e m a -> ExceptT e m Bool Source #

lte :: Ord a => ExceptT e m a -> ExceptT e m a -> ExceptT e m Bool Source #

gte :: Ord a => ExceptT e m a -> ExceptT e m a -> ExceptT e m Bool Source #

min :: Ord a => ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

max :: Ord a => ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

(Monoid t, Applicative m) => CompareExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => WriterT t m a -> WriterT t m a -> WriterT t m Bool Source #

neq :: Eq a => WriterT t m a -> WriterT t m a -> WriterT t m Bool Source #

lt :: Ord a => WriterT t m a -> WriterT t m a -> WriterT t m Bool Source #

gt :: Ord a => WriterT t m a -> WriterT t m a -> WriterT t m Bool Source #

lte :: Ord a => WriterT t m a -> WriterT t m a -> WriterT t m Bool Source #

gte :: Ord a => WriterT t m a -> WriterT t m a -> WriterT t m Bool Source #

min :: Ord a => WriterT t m a -> WriterT t m a -> WriterT t m a Source #

max :: Ord a => WriterT t m a -> WriterT t m a -> WriterT t m a Source #

CompareExp e => CompareExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

eq :: Eq a => Exp e a -> Exp e a -> Exp e Bool Source #

neq :: Eq a => Exp e a -> Exp e a -> Exp e Bool Source #

lt :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

gt :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

lte :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

gte :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

min :: Ord a => Exp e a -> Exp e a -> Exp e a Source #

max :: Ord a => Exp e a -> Exp e a -> Exp e a Source #

(CompareExp e1, CompareExp e2) => CompareExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) Bool Source #

neq :: Eq a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) Bool Source #

lt :: Ord a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) Bool Source #

gt :: Ord a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) Bool Source #

lte :: Ord a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) Bool Source #

gte :: Ord a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) Bool Source #

min :: Ord a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

max :: Ord a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

Applicative m => CompareExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

eq :: Eq a => ReaderT env m a -> ReaderT env m a -> ReaderT env m Bool Source #

neq :: Eq a => ReaderT env m a -> ReaderT env m a -> ReaderT env m Bool Source #

lt :: Ord a => ReaderT env m a -> ReaderT env m a -> ReaderT env m Bool Source #

gt :: Ord a => ReaderT env m a -> ReaderT env m a -> ReaderT env m Bool Source #

lte :: Ord a => ReaderT env m a -> ReaderT env m a -> ReaderT env m Bool Source #

gte :: Ord a => ReaderT env m a -> ReaderT env m a -> ReaderT env m Bool Source #

min :: Ord a => ReaderT env m a -> ReaderT env m a -> ReaderT env m a Source #

max :: Ord a => ReaderT env m a -> ReaderT env m a -> ReaderT env m a Source #

(==) :: (Eq a, CompareExp e) => e a -> e a -> e Bool infix 4 Source #

(/=) :: (Eq a, CompareExp e) => e a -> e a -> e Bool infix 4 Source #

(<) :: (Ord a, CompareExp e) => e a -> e a -> e Bool infix 4 Source #

(>) :: (Ord a, CompareExp e) => e a -> e a -> e Bool infix 4 Source #

(<=) :: (Ord a, CompareExp e) => e a -> e a -> e Bool infix 4 Source #

(>=) :: (Ord a, CompareExp e) => e a -> e a -> e Bool infix 4 Source #

(==!) :: (ConstExp e, CompareExp e, DinoType a) => e a -> a -> e Bool infix 4 Source #

Check equality against a constant value

Conditionals

data a :-> b infix 1 Source #

Representation of a case in cases

Constructors

a :-> b infix 1 
Instances
Bifunctor (:->) Source # 
Instance details

Defined in Dino.Expression

Methods

bimap :: (a -> b) -> (c -> d) -> (a :-> c) -> b :-> d #

first :: (a -> b) -> (a :-> c) -> b :-> c #

second :: (b -> c) -> (a :-> b) -> a :-> c #

Functor ((:->) a) Source # 
Instance details

Defined in Dino.Expression

Methods

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

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

Foldable ((:->) a) Source # 
Instance details

Defined in Dino.Expression

Methods

fold :: Monoid m => (a :-> m) -> m #

foldMap :: Monoid m => (a0 -> m) -> (a :-> a0) -> m #

foldr :: (a0 -> b -> b) -> b -> (a :-> a0) -> b #

foldr' :: (a0 -> b -> b) -> b -> (a :-> a0) -> b #

foldl :: (b -> a0 -> b) -> b -> (a :-> a0) -> b #

foldl' :: (b -> a0 -> b) -> b -> (a :-> a0) -> b #

foldr1 :: (a0 -> a0 -> a0) -> (a :-> a0) -> a0 #

foldl1 :: (a0 -> a0 -> a0) -> (a :-> a0) -> a0 #

toList :: (a :-> a0) -> [a0] #

null :: (a :-> a0) -> Bool #

length :: (a :-> a0) -> Int #

elem :: Eq a0 => a0 -> (a :-> a0) -> Bool #

maximum :: Ord a0 => (a :-> a0) -> a0 #

minimum :: Ord a0 => (a :-> a0) -> a0 #

sum :: Num a0 => (a :-> a0) -> a0 #

product :: Num a0 => (a :-> a0) -> a0 #

Traversable ((:->) a) Source # 
Instance details

Defined in Dino.Expression

Methods

traverse :: Applicative f => (a0 -> f b) -> (a :-> a0) -> f (a :-> b) #

sequenceA :: Applicative f => (a :-> f a0) -> f (a :-> a0) #

mapM :: Monad m => (a0 -> m b) -> (a :-> a0) -> m (a :-> b) #

sequence :: Monad m => (a :-> m a0) -> m (a :-> a0) #

(Eq a, Eq b) => Eq (a :-> b) Source # 
Instance details

Defined in Dino.Expression

Methods

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

(/=) :: (a :-> b) -> (a :-> b) -> Bool #

(Show a, Show b) => Show (a :-> b) Source # 
Instance details

Defined in Dino.Expression

Methods

showsPrec :: Int -> (a :-> b) -> ShowS #

show :: (a :-> b) -> String #

showList :: [a :-> b] -> ShowS #

(-->) :: a -> b -> a :-> b infix 1 Source #

Construct a case in cases, match, etc.

Example:

beaufortScale :: _ => Exp e a -> Exp e Text
beaufortScale v = match v
  [ (< 0.5)   --> "calm"
  , (< 13.8)  --> "breeze"
  , (< 24.5)  --> "gale" ]
  ( Otherwise --> "storm" )

data Otherwise Source #

Marker for the default case in cases

Constructors

Otherwise 

class CondExpFO e where Source #

Helper class to CondExp containing only first-order constructs

The reason for having this class is that there are types for which CondExpFO can be derived but CondExp cannot.

Minimal complete definition

Nothing

Methods

just :: e a -> e (Maybe a) Source #

Construct an optional value that is present

cases Source #

Arguments

:: [e Bool :-> e a]

Guarded expressions

-> (Otherwise :-> e a)

Fall-through case

-> e a 

Case expression

partial_cases Source #

Arguments

:: HasCallStack 
=> [e Bool :-> e a]

Guarded expressions

-> e a 

Case expression without fall-through

Evaluation may fail if the cases are not complete.

just :: Applicative e => e a -> e (Maybe a) Source #

Construct an optional value that is present

cases Source #

Arguments

:: Monad e 
=> [e Bool :-> e a]

Guarded expressions

-> (Otherwise :-> e a)

Fall-through case

-> e a 

Case expression

partial_cases Source #

Arguments

:: (Monad e, HasCallStack) 
=> [e Bool :-> e a]

Guarded expressions

-> e a 

Case expression without fall-through

Evaluation may fail if the cases are not complete.

Instances
CondExpFO Maybe Source # 
Instance details

Defined in Dino.Interpretation

CondExpFO Identity Source # 
Instance details

Defined in Dino.Interpretation

CondExpFO DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

CondExpFO Reified Source # 
Instance details

Defined in Dino.Interpretation

CondExpFO (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

just :: Either e a -> Either e (Maybe a) Source #

cases :: [Either e Bool :-> Either e a] -> (Otherwise :-> Either e a) -> Either e a Source #

partial_cases :: HasCallStack => [Either e Bool :-> Either e a] -> Either e a Source #

CondExpFO e => CondExpFO (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

CondExpFO e => CondExpFO (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

CondExpFO e => CondExpFO (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Monad e => CondExpFO (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

CondExpFO e => CondExpFO (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Monoid e => CondExpFO (Fold e) Source #

Interprets all branches

Instance details

Defined in Dino.Interpretation

Methods

just :: Fold e a -> Fold e (Maybe a) Source #

cases :: [Fold e Bool :-> Fold e a] -> (Otherwise :-> Fold e a) -> Fold e a Source #

partial_cases :: HasCallStack => [Fold e Bool :-> Fold e a] -> Fold e a Source #

Monad m => CondExpFO (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

just :: ExceptT e m a -> ExceptT e m (Maybe a) Source #

cases :: [ExceptT e m Bool :-> ExceptT e m a] -> (Otherwise :-> ExceptT e m a) -> ExceptT e m a Source #

partial_cases :: HasCallStack => [ExceptT e m Bool :-> ExceptT e m a] -> ExceptT e m a Source #

(Monoid t, Monad m) => CondExpFO (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

just :: WriterT t m a -> WriterT t m (Maybe a) Source #

cases :: [WriterT t m Bool :-> WriterT t m a] -> (Otherwise :-> WriterT t m a) -> WriterT t m a Source #

partial_cases :: HasCallStack => [WriterT t m Bool :-> WriterT t m a] -> WriterT t m a Source #

CondExpFO e => CondExpFO (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

just :: Exp e a -> Exp e (Maybe a) Source #

cases :: [Exp e Bool :-> Exp e a] -> (Otherwise :-> Exp e a) -> Exp e a Source #

partial_cases :: HasCallStack => [Exp e Bool :-> Exp e a] -> Exp e a Source #

(CondExpFO e1, CondExpFO e2) => CondExpFO (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

just :: (e1 :×: e2) a -> (e1 :×: e2) (Maybe a) Source #

cases :: [(e1 :×: e2) Bool :-> (e1 :×: e2) a] -> (Otherwise :-> (e1 :×: e2) a) -> (e1 :×: e2) a Source #

partial_cases :: HasCallStack => [(e1 :×: e2) Bool :-> (e1 :×: e2) a] -> (e1 :×: e2) a Source #

Monad m => CondExpFO (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

just :: ReaderT env m a -> ReaderT env m (Maybe a) Source #

cases :: [ReaderT env m Bool :-> ReaderT env m a] -> (Otherwise :-> ReaderT env m a) -> ReaderT env m a Source #

partial_cases :: HasCallStack => [ReaderT env m Bool :-> ReaderT env m a] -> ReaderT env m a Source #

class CondExpFO e => CondExp e where Source #

Expressions supporting conditionals

The default implementations are for monadic interpretations.

Minimal complete definition

Nothing

Methods

maybe Source #

Arguments

:: DinoType a 
=> e b

Result when nothing

-> (e a -> e b)

Result when just

-> e (Maybe a)

Value to deconstruct

-> e b 

Deconstruct an optional value

maybe Source #

Arguments

:: Monad e 
=> e b

Result when nothing

-> (e a -> e b)

Result when just

-> e (Maybe a)

Value to deconstruct

-> e b 

Deconstruct an optional value

Instances
CondExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => Maybe b -> (Maybe a -> Maybe b) -> Maybe (Maybe a) -> Maybe b Source #

CondExp Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => Identity b -> (Identity a -> Identity b) -> Identity (Maybe a) -> Identity b Source #

CondExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

CondExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => Either e b -> (Either e a -> Either e b) -> Either e (Maybe a) -> Either e b Source #

(CondExpFO e, VarExp e, CondIntensional e) => CondExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

CondExp e => CondExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

CondExp e => CondExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

(CondExpFO e, VarExp e, CondIntensional e) => CondExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => Intensional e b -> (Intensional e a -> Intensional e b) -> Intensional e (Maybe a) -> Intensional e b Source #

Monoid e => CondExp (Fold e) Source #

Interprets all branches

Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => Fold e b -> (Fold e a -> Fold e b) -> Fold e (Maybe a) -> Fold e b Source #

Monad m => CondExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => ExceptT e m b -> (ExceptT e m a -> ExceptT e m b) -> ExceptT e m (Maybe a) -> ExceptT e m b Source #

(Monoid t, Monad m) => CondExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => WriterT t m b -> (WriterT t m a -> WriterT t m b) -> WriterT t m (Maybe a) -> WriterT t m b Source #

CondExp e => CondExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

maybe :: DinoType a => Exp e b -> (Exp e a -> Exp e b) -> Exp e (Maybe a) -> Exp e b Source #

Monad m => CondExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

maybe :: DinoType a => ReaderT env m b -> (ReaderT env m a -> ReaderT env m b) -> ReaderT env m (Maybe a) -> ReaderT env m b Source #

nothing :: (ConstExp e, DinoType a) => e (Maybe a) Source #

Construct an optional value that is missing

isJust :: (ConstExp e, CondExp e, DinoType a) => e (Maybe a) -> e Bool Source #

match Source #

Arguments

:: CondExpFO e 
=> a

Scrutinee

-> [(a -> e Bool) :-> e b]

Cases

-> (Otherwise :-> e b)

Fall-through case

-> e b 

Case expression using Boolean functions for matching

matchConst Source #

Arguments

:: (ConstExp e, CompareExp e, CondExpFO e, DinoType a) 
=> e a

Scrutinee

-> [a :-> e b]

Cases

-> (Otherwise :-> e b)

Fall-through case

-> e b 

Case expression matching a value against constants

Example:

operate c a = matchConst c
  [+ --> a + 1
  ,- --> a - 1
  ]
  (Otherwise --> a)

matchConstFull Source #

Arguments

:: (ConstExp e, CompareExp e, CondExpFO e, DinoType a, Show a, Enum a, Bounded a, HasCallStack) 
=> e a

Scrutinee

-> [a :-> e b]

Cases

-> e b 

A Version of matchConst for enumerations where the cases cover the whole domain

An error is thrown if the cases do not cover the whole domain.

ifThenElse Source #

Arguments

:: CondExpFO e 
=> e Bool

Condition

-> e a

True branch

-> e a

False branch

-> e a 

Conditional expression

Enable RebindableSyntax to use the standard syntax if a then b else c for calling this function.

fromMaybe :: (CondExp e, DinoType a) => e a -> e (Maybe a) -> e a Source #

Lists

class ListExpFO e where Source #

Helper class to ListExp containing only first-order constructs

The reason for having this class is that there are types for which ListExpFO can be derived but ListExp cannot.

Minimal complete definition

Nothing

Methods

range Source #

Arguments

:: Enum a 
=> e a

Lower bound (inclusive)

-> e a

Upper bound (inclusive)

-> e [a] 

list :: DinoType a => [e a] -> e [a] Source #

headE :: e [a] -> e (Maybe a) Source #

append :: e [a] -> e [a] -> e [a] Source #

range Source #

Arguments

:: (Applicative e, Enum a) 
=> e a

Lower bound (inclusive)

-> e a

Upper bound (inclusive)

-> e [a] 

list :: Applicative e => [e a] -> e [a] Source #

headE :: Applicative e => e [a] -> e (Maybe a) Source #

append :: Applicative e => e [a] -> e [a] -> e [a] Source #

Instances
ListExpFO Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => Maybe a -> Maybe a -> Maybe [a] Source #

list :: DinoType a => [Maybe a] -> Maybe [a] Source #

headE :: Maybe [a] -> Maybe (Maybe a) Source #

append :: Maybe [a] -> Maybe [a] -> Maybe [a] Source #

ListExpFO Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => Identity a -> Identity a -> Identity [a] Source #

list :: DinoType a => [Identity a] -> Identity [a] Source #

headE :: Identity [a] -> Identity (Maybe a) Source #

append :: Identity [a] -> Identity [a] -> Identity [a] Source #

ListExpFO DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

ListExpFO Reified Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => Reified a -> Reified a -> Reified [a] Source #

list :: DinoType a => [Reified a] -> Reified [a] Source #

headE :: Reified [a] -> Reified (Maybe a) Source #

append :: Reified [a] -> Reified [a] -> Reified [a] Source #

ListExpFO (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => Either e a -> Either e a -> Either e [a] Source #

list :: DinoType a => [Either e a] -> Either e [a] Source #

headE :: Either e [a] -> Either e (Maybe a) Source #

append :: Either e [a] -> Either e [a] -> Either e [a] Source #

ListExpFO e => ListExpFO (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

ListExpFO e => ListExpFO (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

ListExpFO e => ListExpFO (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Monad e => ListExpFO (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => EvalEnv e a -> EvalEnv e a -> EvalEnv e [a] Source #

list :: DinoType a => [EvalEnv e a] -> EvalEnv e [a] Source #

headE :: EvalEnv e [a] -> EvalEnv e (Maybe a) Source #

append :: EvalEnv e [a] -> EvalEnv e [a] -> EvalEnv e [a] Source #

ListExpFO e => ListExpFO (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => Intensional e a -> Intensional e a -> Intensional e [a] Source #

list :: DinoType a => [Intensional e a] -> Intensional e [a] Source #

headE :: Intensional e [a] -> Intensional e (Maybe a) Source #

append :: Intensional e [a] -> Intensional e [a] -> Intensional e [a] Source #

Monoid e => ListExpFO (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => Fold e a -> Fold e a -> Fold e [a] Source #

list :: DinoType a => [Fold e a] -> Fold e [a] Source #

headE :: Fold e [a] -> Fold e (Maybe a) Source #

append :: Fold e [a] -> Fold e [a] -> Fold e [a] Source #

Monad m => ListExpFO (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => ExceptT e m a -> ExceptT e m a -> ExceptT e m [a] Source #

list :: DinoType a => [ExceptT e m a] -> ExceptT e m [a] Source #

headE :: ExceptT e m [a] -> ExceptT e m (Maybe a) Source #

append :: ExceptT e m [a] -> ExceptT e m [a] -> ExceptT e m [a] Source #

(Monoid t, Monad m) => ListExpFO (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => WriterT t m a -> WriterT t m a -> WriterT t m [a] Source #

list :: DinoType a => [WriterT t m a] -> WriterT t m [a] Source #

headE :: WriterT t m [a] -> WriterT t m (Maybe a) Source #

append :: WriterT t m [a] -> WriterT t m [a] -> WriterT t m [a] Source #

ListExpFO e => ListExpFO (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

range :: Enum a => Exp e a -> Exp e a -> Exp e [a] Source #

list :: DinoType a => [Exp e a] -> Exp e [a] Source #

headE :: Exp e [a] -> Exp e (Maybe a) Source #

append :: Exp e [a] -> Exp e [a] -> Exp e [a] Source #

(ListExpFO e1, ListExpFO e2) => ListExpFO (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) [a] Source #

list :: DinoType a => [(e1 :×: e2) a] -> (e1 :×: e2) [a] Source #

headE :: (e1 :×: e2) [a] -> (e1 :×: e2) (Maybe a) Source #

append :: (e1 :×: e2) [a] -> (e1 :×: e2) [a] -> (e1 :×: e2) [a] Source #

Monad m => ListExpFO (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

range :: Enum a => ReaderT env m a -> ReaderT env m a -> ReaderT env m [a] Source #

list :: DinoType a => [ReaderT env m a] -> ReaderT env m [a] Source #

headE :: ReaderT env m [a] -> ReaderT env m (Maybe a) Source #

append :: ReaderT env m [a] -> ReaderT env m [a] -> ReaderT env m [a] Source #

class ListExpFO e => ListExp e where Source #

Minimal complete definition

Nothing

Methods

mapE :: DinoType a => (e a -> e b) -> e [a] -> e [b] Source #

dropWhileE :: DinoType a => (e a -> e Bool) -> e [a] -> e [a] Source #

foldE Source #

Arguments

:: (DinoType a, DinoType b) 
=> (e a -> e b -> e a)

Reducer function

-> e a

Initial value

-> e [b]

List to reduce (traversed left-to-right)

-> e a 

Left fold

mapE :: Monad e => (e a -> e b) -> e [a] -> e [b] Source #

dropWhileE :: Monad e => (e a -> e Bool) -> e [a] -> e [a] Source #

foldE Source #

Arguments

:: Monad e 
=> (e a -> e b -> e a)

Reducer function

-> e a

Initial value

-> e [b]

List to reduce (traversed left-to-right)

-> e a 

Left fold

Instances
ListExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (Maybe a -> Maybe b) -> Maybe [a] -> Maybe [b] Source #

dropWhileE :: DinoType a => (Maybe a -> Maybe Bool) -> Maybe [a] -> Maybe [a] Source #

foldE :: (DinoType a, DinoType b) => (Maybe a -> Maybe b -> Maybe a) -> Maybe a -> Maybe [b] -> Maybe a Source #

ListExp Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (Identity a -> Identity b) -> Identity [a] -> Identity [b] Source #

dropWhileE :: DinoType a => (Identity a -> Identity Bool) -> Identity [a] -> Identity [a] Source #

foldE :: (DinoType a, DinoType b) => (Identity a -> Identity b -> Identity a) -> Identity a -> Identity [b] -> Identity a Source #

ListExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

ListExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (Either e a -> Either e b) -> Either e [a] -> Either e [b] Source #

dropWhileE :: DinoType a => (Either e a -> Either e Bool) -> Either e [a] -> Either e [a] Source #

foldE :: (DinoType a, DinoType b) => (Either e a -> Either e b -> Either e a) -> Either e a -> Either e [b] -> Either e a Source #

(ListExpFO e, VarExp e, ListIntensional e) => ListExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

ListExp e => ListExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

ListExp e => ListExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

(ListExpFO e, VarExp e, ListIntensional e) => ListExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (Intensional e a -> Intensional e b) -> Intensional e [a] -> Intensional e [b] Source #

dropWhileE :: DinoType a => (Intensional e a -> Intensional e Bool) -> Intensional e [a] -> Intensional e [a] Source #

foldE :: (DinoType a, DinoType b) => (Intensional e a -> Intensional e b -> Intensional e a) -> Intensional e a -> Intensional e [b] -> Intensional e a Source #

Monoid e => ListExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (Fold e a -> Fold e b) -> Fold e [a] -> Fold e [b] Source #

dropWhileE :: DinoType a => (Fold e a -> Fold e Bool) -> Fold e [a] -> Fold e [a] Source #

foldE :: (DinoType a, DinoType b) => (Fold e a -> Fold e b -> Fold e a) -> Fold e a -> Fold e [b] -> Fold e a Source #

Monad m => ListExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (ExceptT e m a -> ExceptT e m b) -> ExceptT e m [a] -> ExceptT e m [b] Source #

dropWhileE :: DinoType a => (ExceptT e m a -> ExceptT e m Bool) -> ExceptT e m [a] -> ExceptT e m [a] Source #

foldE :: (DinoType a, DinoType b) => (ExceptT e m a -> ExceptT e m b -> ExceptT e m a) -> ExceptT e m a -> ExceptT e m [b] -> ExceptT e m a Source #

(Monoid t, Monad m) => ListExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (WriterT t m a -> WriterT t m b) -> WriterT t m [a] -> WriterT t m [b] Source #

dropWhileE :: DinoType a => (WriterT t m a -> WriterT t m Bool) -> WriterT t m [a] -> WriterT t m [a] Source #

foldE :: (DinoType a, DinoType b) => (WriterT t m a -> WriterT t m b -> WriterT t m a) -> WriterT t m a -> WriterT t m [b] -> WriterT t m a Source #

ListExp e => ListExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

mapE :: DinoType a => (Exp e a -> Exp e b) -> Exp e [a] -> Exp e [b] Source #

dropWhileE :: DinoType a => (Exp e a -> Exp e Bool) -> Exp e [a] -> Exp e [a] Source #

foldE :: (DinoType a, DinoType b) => (Exp e a -> Exp e b -> Exp e a) -> Exp e a -> Exp e [b] -> Exp e a Source #

Monad m => ListExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

mapE :: DinoType a => (ReaderT env m a -> ReaderT env m b) -> ReaderT env m [a] -> ReaderT env m [b] Source #

dropWhileE :: DinoType a => (ReaderT env m a -> ReaderT env m Bool) -> ReaderT env m [a] -> ReaderT env m [a] Source #

foldE :: (DinoType a, DinoType b) => (ReaderT env m a -> ReaderT env m b -> ReaderT env m a) -> ReaderT env m a -> ReaderT env m [b] -> ReaderT env m a Source #

Tuples

class TupleExp e where Source #

Minimal complete definition

Nothing

Methods

pair :: e a -> e b -> e (a, b) Source #

fstE :: e (a, b) -> e a Source #

sndE :: e (a, b) -> e b Source #

pair :: Applicative e => e a -> e b -> e (a, b) Source #

fstE :: Applicative e => e (a, b) -> e a Source #

sndE :: Applicative e => e (a, b) -> e b Source #

Instances
TupleExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: Maybe a -> Maybe b -> Maybe (a, b) Source #

fstE :: Maybe (a, b) -> Maybe a Source #

sndE :: Maybe (a, b) -> Maybe b Source #

TupleExp Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: Identity a -> Identity b -> Identity (a, b) Source #

fstE :: Identity (a, b) -> Identity a Source #

sndE :: Identity (a, b) -> Identity b Source #

TupleExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

TupleExp Reified Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: Reified a -> Reified b -> Reified (a, b) Source #

fstE :: Reified (a, b) -> Reified a Source #

sndE :: Reified (a, b) -> Reified b Source #

TupleExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: Either e a -> Either e b -> Either e (a, b) Source #

fstE :: Either e (a, b) -> Either e a Source #

sndE :: Either e (a, b) -> Either e b Source #

TupleExp e => TupleExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

TupleExp e => TupleExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

TupleExp e => TupleExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Monad e => TupleExp (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: EvalEnv e a -> EvalEnv e b -> EvalEnv e (a, b) Source #

fstE :: EvalEnv e (a, b) -> EvalEnv e a Source #

sndE :: EvalEnv e (a, b) -> EvalEnv e b Source #

TupleExp e => TupleExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: Intensional e a -> Intensional e b -> Intensional e (a, b) Source #

fstE :: Intensional e (a, b) -> Intensional e a Source #

sndE :: Intensional e (a, b) -> Intensional e b Source #

Monoid e => TupleExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: Fold e a -> Fold e b -> Fold e (a, b) Source #

fstE :: Fold e (a, b) -> Fold e a Source #

sndE :: Fold e (a, b) -> Fold e b Source #

Monad m => TupleExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: ExceptT e m a -> ExceptT e m b -> ExceptT e m (a, b) Source #

fstE :: ExceptT e m (a, b) -> ExceptT e m a Source #

sndE :: ExceptT e m (a, b) -> ExceptT e m b Source #

(Monoid t, Monad m) => TupleExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: WriterT t m a -> WriterT t m b -> WriterT t m (a, b) Source #

fstE :: WriterT t m (a, b) -> WriterT t m a Source #

sndE :: WriterT t m (a, b) -> WriterT t m b Source #

(TupleExp e1, TupleExp e2) => TupleExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: (e1 :×: e2) a -> (e1 :×: e2) b -> (e1 :×: e2) (a, b) Source #

fstE :: (e1 :×: e2) (a, b) -> (e1 :×: e2) a Source #

sndE :: (e1 :×: e2) (a, b) -> (e1 :×: e2) b Source #

Monad m => TupleExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

pair :: ReaderT env m a -> ReaderT env m b -> ReaderT env m (a, b) Source #

fstE :: ReaderT env m (a, b) -> ReaderT env m a Source #

sndE :: ReaderT env m (a, b) -> ReaderT env m b Source #

Let bindings

class LetExp e where Source #

Minimal complete definition

Nothing

Methods

letE Source #

Arguments

:: DinoType a 
=> Text

Variable base name

-> e a

Value to share

-> (e a -> e b)

Body

-> e b 

Share a value in a calculation

The default implementation of letE implements call-by-value.

letE Source #

Arguments

:: Monad e 
=> Text

Variable base name

-> e a

Value to share

-> (e a -> e b)

Body

-> e b 

Share a value in a calculation

The default implementation of letE implements call-by-value.

Instances
LetExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> Maybe a -> (Maybe a -> Maybe b) -> Maybe b Source #

LetExp Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> Identity a -> (Identity a -> Identity b) -> Identity b Source #

LetExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> DinoTypeRep a -> (DinoTypeRep a -> DinoTypeRep b) -> DinoTypeRep b Source #

LetExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> Either e a -> (Either e a -> Either e b) -> Either e b Source #

(VarExp e, LetIntensional e) => LetExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

LetExp e => LetExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

LetExp e => LetExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

(VarExp e, LetIntensional e) => LetExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> Intensional e a -> (Intensional e a -> Intensional e b) -> Intensional e b Source #

Monoid e => LetExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> Fold e a -> (Fold e a -> Fold e b) -> Fold e b Source #

Monad m => LetExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> ExceptT e m a -> (ExceptT e m a -> ExceptT e m b) -> ExceptT e m b Source #

(Monoid t, Monad m) => LetExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> WriterT t m a -> (WriterT t m a -> WriterT t m b) -> WriterT t m b Source #

LetExp e => LetExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

letE :: DinoType a => Text -> Exp e a -> (Exp e a -> Exp e b) -> Exp e b Source #

Monad m => LetExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

letE :: DinoType a => Text -> ReaderT env m a -> (ReaderT env m a -> ReaderT env m b) -> ReaderT env m b Source #

share Source #

Arguments

:: (LetExp e, DinoType a) 
=> e a

Value to share

-> (e a -> e b)

Body

-> e b 

Share a value in a calculation

Like letE but with the variable base name fixed to "share".

shared Source #

Arguments

:: (LetExp e, DinoType a) 
=> (e a -> e b)

Body

-> e a

Value to share

-> e b 

Make a function with a shared argument

shared = flip share

Like letE but with the variable base name fixed to "share".

Records

data Field (f :: Symbol) Source #

Constructors

Field 
Instances
f1 ~ f2 => IsLabel f1 (Field f2) Source # 
Instance details

Defined in Dino.Expression

Methods

fromLabel :: Field f2 #

class FieldExp e where Source #

Minimal complete definition

Nothing

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> e r -> e a Source #

getField :: forall proxy f r a. (Applicative e, KnownSymbol f, HasField f r a) => proxy f -> e r -> e a Source #

Instances
FieldExp Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Maybe r -> Maybe a Source #

FieldExp Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Identity r -> Identity a Source #

FieldExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> DinoTypeRep r -> DinoTypeRep a Source #

FieldExp Reified Source #

Field name prepended with #

Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Reified r -> Reified a Source #

FieldExp (Either e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Either e r -> Either e a Source #

FieldExp e => FieldExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> CollectAssertions e r -> CollectAssertions e a Source #

FieldExp e => FieldExp (AssertViaMonadThrow e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> AssertViaMonadThrow e r -> AssertViaMonadThrow e a Source #

FieldExp e => FieldExp (AssertViaMonadError e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> AssertViaMonadError e r -> AssertViaMonadError e a Source #

Monad e => FieldExp (EvalEnv e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> EvalEnv e r -> EvalEnv e a Source #

FieldExp e => FieldExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Intensional e r -> Intensional e a Source #

Monoid e => FieldExp (Fold e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Fold e r -> Fold e a Source #

Monad m => FieldExp (ExceptT e m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> ExceptT e m r -> ExceptT e m a Source #

(Monoid t, Monad m) => FieldExp (WriterT t m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> WriterT t m r -> WriterT t m a Source #

FieldExp e => FieldExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Exp e r -> Exp e a Source #

(FieldExp e1, FieldExp e2) => FieldExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> (e1 :×: e2) r -> (e1 :×: e2) a Source #

Monad m => FieldExp (ReaderT env m) Source # 
Instance details

Defined in Dino.Interpretation

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> ReaderT env m r -> ReaderT env m a Source #

field :: (FieldExp e, KnownSymbol f, HasField f r a, DinoType a) => Field f -> e r -> e a Source #

Extract a field from a record

Use as follows (with OverloadedLabels):

field #name $ field #driver car

(<.) :: (FieldExp e, KnownSymbol f, HasField f r a, DinoType a) => Field f -> e r -> e a infixr 9 Source #

Extract a field from a record

Use as follows (with OverloadedLabels):

#name <. #driver <. car

Annotations

class AnnExp ann e where Source #

Minimal complete definition

Nothing

Methods

ann :: ann -> e a -> e a Source #

Annotate an expression

Instances
AnnExp ann e => AnnExp ann (Exp e :: k -> Type) Source # 
Instance details

Defined in Dino.Expression

Methods

ann :: ann -> Exp e a -> Exp e a Source #

AnnExp ann Maybe Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> Maybe a -> Maybe a Source #

AnnExp ann Identity Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> Identity a -> Identity a Source #

AnnExp ann DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> DinoTypeRep a -> DinoTypeRep a Source #

AnnExp Text Reified Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: Text -> Reified a -> Reified a Source #

AnnExp ann e => AnnExp ann (CollectAssertions e :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> CollectAssertions e a -> CollectAssertions e a Source #

AnnExp ann e => AnnExp ann (AssertViaMonadThrow e :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> AssertViaMonadThrow e a -> AssertViaMonadThrow e a Source #

AnnExp ann e => AnnExp ann (AssertViaMonadError e :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> AssertViaMonadError e a -> AssertViaMonadError e a Source #

AnnExp ann (EvalEnv e :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> EvalEnv e a -> EvalEnv e a Source #

AnnExp ann e => AnnExp ann (Intensional e :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> Intensional e a -> Intensional e a Source #

AnnExp ann (Fold e :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> Fold e a -> Fold e a Source #

AnnExp ann (Either e :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> Either e a -> Either e a Source #

(AnnExp ann e1, AnnExp ann e2) => AnnExp ann (e1 :×: e2 :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

AnnExp ann (WriterT t m :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> WriterT t m a -> WriterT t m a Source #

AnnExp ann (ExceptT e m :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> ExceptT e m a -> ExceptT e m a Source #

AnnExp ann (ReaderT env m :: Type -> Type) Source # 
Instance details

Defined in Dino.Interpretation

Methods

ann :: ann -> ReaderT env m a -> ReaderT env m a Source #

Assertions

class AssertExp e where Source #

Minimal complete definition

Nothing

Methods

assert Source #

Arguments

:: Text

Assertion label

-> e Bool

Condition that should be true

-> e a

Expression to attach the assertion to

-> e a 

Assert that a condition is true

Interpretations can choose whether to ignore the assertion or to check its validity. The default implementation ignores the assertion.

The following must hold for any monadic interpretation:

assert lab c a
  ==
(assert lab c (return ()) >> return a)

assertEq Source #

Arguments

:: (Eq a, Show a) 
=> Text

Assertion label

-> e a

Reference expression

-> e a

Actual expression

-> e a 

Assert that an expression is semantically equivalent to a reference expression

Interpretations can choose whether to ignore the assertion or to check its validity. The default implementation ignores the assertion.

The following must hold for any monadic interpretation:

assertEq lab ref act
  ==
( do a <- act
     assertEq lab ref (return a)
     return a
)
Instances
AssertExp Maybe Source #

Ignoring assertion for efficiency

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> Maybe Bool -> Maybe a -> Maybe a Source #

assertEq :: (Eq a, Show a) => Text -> Maybe a -> Maybe a -> Maybe a Source #

AssertExp Identity Source #

Ignoring assertion for efficiency

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> Identity Bool -> Identity a -> Identity a Source #

assertEq :: (Eq a, Show a) => Text -> Identity a -> Identity a -> Identity a Source #

AssertExp DinoTypeRep Source # 
Instance details

Defined in Dino.Interpretation

AssertExp Reified Source #

Ignores the assertion

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> Reified Bool -> Reified a -> Reified a Source #

assertEq :: (Eq a, Show a) => Text -> Reified a -> Reified a -> Reified a Source #

AssertExp (Either e) Source #

Ignoring assertion for efficiency

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> Either e Bool -> Either e a -> Either e a Source #

assertEq :: (Eq a, Show a) => Text -> Either e a -> Either e a -> Either e a Source #

AssertExp (CollectAssertions e) Source # 
Instance details

Defined in Dino.Interpretation

MonadThrow e => AssertExp (AssertViaMonadThrow e) Source #

Throws InvalidAssertion in the underlying monad

Instance details

Defined in Dino.Interpretation

MonadError InvalidAssertion e => AssertExp (AssertViaMonadError e) Source #

Throws InvalidAssertion in the underlying monad

Instance details

Defined in Dino.Interpretation

AssertExp e => AssertExp (Intensional e) Source # 
Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> Intensional e Bool -> Intensional e a -> Intensional e a Source #

assertEq :: (Eq a, Show a) => Text -> Intensional e a -> Intensional e a -> Intensional e a Source #

AssertExp (Fold e) Source #

Ignoring assertion

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> Fold e Bool -> Fold e a -> Fold e a Source #

assertEq :: (Eq a, Show a) => Text -> Fold e a -> Fold e a -> Fold e a Source #

AssertExp (ExceptT e m) Source #

Ignoring assertion for efficiency

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> ExceptT e m Bool -> ExceptT e m a -> ExceptT e m a Source #

assertEq :: (Eq a, Show a) => Text -> ExceptT e m a -> ExceptT e m a -> ExceptT e m a Source #

AssertExp (WriterT t m) Source #

Ignoring assertion for efficiency

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> WriterT t m Bool -> WriterT t m a -> WriterT t m a Source #

assertEq :: (Eq a, Show a) => Text -> WriterT t m a -> WriterT t m a -> WriterT t m a Source #

AssertExp e => AssertExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

assert :: Text -> Exp e Bool -> Exp e a -> Exp e a Source #

assertEq :: (Eq a, Show a) => Text -> Exp e a -> Exp e a -> Exp e a Source #

(AssertExp e1, AssertExp e2) => AssertExp (e1 :×: e2) Source # 
Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> (e1 :×: e2) Bool -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

assertEq :: (Eq a, Show a) => Text -> (e1 :×: e2) a -> (e1 :×: e2) a -> (e1 :×: e2) a Source #

AssertExp (ReaderT env m) Source #

Ignoring assertion for efficiency

Instance details

Defined in Dino.Interpretation

Methods

assert :: Text -> ReaderT env m Bool -> ReaderT env m a -> ReaderT env m a Source #

assertEq :: (Eq a, Show a) => Text -> ReaderT env m a -> ReaderT env m a -> ReaderT env m a Source #

Concrete expression wrapper

newtype Exp e a Source #

Useful wrapper to get a concrete type for tagless DSL expressions

The problem solved by this type can be explained as follows:

Suppose you write a numeric expression with the most general type:

myExp1 :: Num e => e
myExp1 = 1+2

And suppose you define an evaluation function as follows:

eval1 :: (forall e . (ConstExp e, NumExp e) => e a) -> a
eval1 = runIdentity

The problem is that we cannot pass myExp1 to eval1:

test1 :: Int
test1 = eval1 myExp1

This leads to:

• Could not deduce (Num (e Int)) ...

And we don't want to change eval1 to

eval1 :: (forall e . (ConstExp e, NumExp e, Num (e a)) => e a) -> a

since this requires the expression to return a number (and not e.g. a Boolean), and it also doesn't help to satisfy any internal numeric expressions that may use a different type than a.

Instead, the solution is to use Exp as follows:

myExp2 :: (ConstExp e, NumExp e, Num a) => Exp e a
myExp2 = 1+2

eval2 :: (forall e . (ConstExp e, NumExp e) => Exp e a) -> a
eval2 = runIdentity . unExp

test2 :: Int
test2 = eval2 myExp2

The trick is that there exists an instance

instance (Num a, ConstExp e, NumExp e) => Num (Exp e a)

So it is enough for eval2 to supply constraints on e, and it will automatically imply the availability of the Num instance.

Constructors

Exp 

Fields

Instances
AnnExp ann e => AnnExp ann (Exp e :: k -> Type) Source # 
Instance details

Defined in Dino.Expression

Methods

ann :: ann -> Exp e a -> Exp e a Source #

(FieldExp e1, e1 ~ e2, KnownSymbol f, HasField f r a, DinoType a) => IsLabel f (Exp e1 r -> Exp e2 a) Source # 
Instance details

Defined in Dino.Expression

Methods

fromLabel :: Exp e1 r -> Exp e2 a #

Monad e => Monad (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

(>>=) :: Exp e a -> (a -> Exp e b) -> Exp e b #

(>>) :: Exp e a -> Exp e b -> Exp e b #

return :: a -> Exp e a #

fail :: String -> Exp e a #

Functor e => Functor (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

fmap :: (a -> b) -> Exp e a -> Exp e b #

(<$) :: a -> Exp e b -> Exp e a #

Applicative e => Applicative (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

pure :: a -> Exp e a #

(<*>) :: Exp e (a -> b) -> Exp e a -> Exp e b #

liftA2 :: (a -> b -> c) -> Exp e a -> Exp e b -> Exp e c #

(*>) :: Exp e a -> Exp e b -> Exp e b #

(<*) :: Exp e a -> Exp e b -> Exp e a #

AssertExp e => AssertExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

assert :: Text -> Exp e Bool -> Exp e a -> Exp e a Source #

assertEq :: (Eq a, Show a) => Text -> Exp e a -> Exp e a -> Exp e a Source #

FieldExp e => FieldExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

getField :: (KnownSymbol f, HasField f r a, DinoType a) => proxy f -> Exp e r -> Exp e a Source #

LetExp e => LetExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

letE :: DinoType a => Text -> Exp e a -> (Exp e a -> Exp e b) -> Exp e b Source #

ListExp e => ListExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

mapE :: DinoType a => (Exp e a -> Exp e b) -> Exp e [a] -> Exp e [b] Source #

dropWhileE :: DinoType a => (Exp e a -> Exp e Bool) -> Exp e [a] -> Exp e [a] Source #

foldE :: (DinoType a, DinoType b) => (Exp e a -> Exp e b -> Exp e a) -> Exp e a -> Exp e [b] -> Exp e a Source #

ListExpFO e => ListExpFO (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

range :: Enum a => Exp e a -> Exp e a -> Exp e [a] Source #

list :: DinoType a => [Exp e a] -> Exp e [a] Source #

headE :: Exp e [a] -> Exp e (Maybe a) Source #

append :: Exp e [a] -> Exp e [a] -> Exp e [a] Source #

CondExp e => CondExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

maybe :: DinoType a => Exp e b -> (Exp e a -> Exp e b) -> Exp e (Maybe a) -> Exp e b Source #

CondExpFO e => CondExpFO (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

just :: Exp e a -> Exp e (Maybe a) Source #

cases :: [Exp e Bool :-> Exp e a] -> (Otherwise :-> Exp e a) -> Exp e a Source #

partial_cases :: HasCallStack => [Exp e Bool :-> Exp e a] -> Exp e a Source #

CompareExp e => CompareExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

eq :: Eq a => Exp e a -> Exp e a -> Exp e Bool Source #

neq :: Eq a => Exp e a -> Exp e a -> Exp e Bool Source #

lt :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

gt :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

lte :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

gte :: Ord a => Exp e a -> Exp e a -> Exp e Bool Source #

min :: Ord a => Exp e a -> Exp e a -> Exp e a Source #

max :: Ord a => Exp e a -> Exp e a -> Exp e a Source #

LogicExp e => LogicExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

not :: Exp e Bool -> Exp e Bool Source #

conj :: Exp e Bool -> Exp e Bool -> Exp e Bool Source #

disj :: Exp e Bool -> Exp e Bool -> Exp e Bool Source #

xor :: Exp e Bool -> Exp e Bool -> Exp e Bool Source #

FracExp e => FracExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

fdiv :: (Fractional a, Eq a) => Exp e a -> Exp e a -> Exp e a Source #

NumExp e => NumExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

add :: Num a => Exp e a -> Exp e a -> Exp e a Source #

sub :: Num a => Exp e a -> Exp e a -> Exp e a Source #

mul :: Num a => Exp e a -> Exp e a -> Exp e a Source #

absE :: Num a => Exp e a -> Exp e a Source #

signE :: Num a => Exp e a -> Exp e a Source #

fromIntegral :: (Integral a, DinoType b, Num b) => Exp e a -> Exp e b Source #

floor :: (RealFrac a, DinoType b, Integral b) => Exp e a -> Exp e b Source #

truncate :: (RealFrac a, DinoType b, Integral b) => Exp e a -> Exp e b Source #

roundN :: RealFrac a => Int -> Exp e a -> Exp e a Source #

ConstExp e => ConstExp (Exp e) Source # 
Instance details

Defined in Dino.Expression

Methods

lit :: DinoType a => a -> Exp e a Source #

Eq (e a) => Eq (Exp e a) Source # 
Instance details

Defined in Dino.Expression

Methods

(==) :: Exp e a -> Exp e a -> Bool #

(/=) :: Exp e a -> Exp e a -> Bool #

(ConstExp e, NumExp e, FracExp e, DinoType a, Fractional a) => Fractional (Exp e a) Source # 
Instance details

Defined in Dino.Expression

Methods

(/) :: Exp e a -> Exp e a -> Exp e a #

recip :: Exp e a -> Exp e a #

fromRational :: Rational -> Exp e a #

(ConstExp e, NumExp e, DinoType a, Num a) => Num (Exp e a) Source # 
Instance details

Defined in Dino.Expression

Methods

(+) :: Exp e a -> Exp e a -> Exp e a #

(-) :: Exp e a -> Exp e a -> Exp e a #

(*) :: Exp e a -> Exp e a -> Exp e a #

negate :: Exp e a -> Exp e a #

abs :: Exp e a -> Exp e a #

signum :: Exp e a -> Exp e a #

fromInteger :: Integer -> Exp e a #

Show (e a) => Show (Exp e a) Source # 
Instance details

Defined in Dino.Expression

Methods

showsPrec :: Int -> Exp e a -> ShowS #

show :: Exp e a -> String #

showList :: [Exp e a] -> ShowS #

(ConstExp e, IsString a, DinoType a) => IsString (Exp e a) Source # 
Instance details

Defined in Dino.Expression

Methods

fromString :: String -> Exp e a #

Derived operations

Operations on Dino lists

sumE :: (ConstExp e, NumExp e, ListExp e, DinoType a, Num a) => e [a] -> e a Source #

andE :: (ConstExp e, LogicExp e, ListExp e) => e [Bool] -> e Bool Source #

orE :: (ConstExp e, LogicExp e, ListExp e) => e [Bool] -> e Bool Source #

allE :: (ConstExp e, LogicExp e, ListExp e, DinoType a) => (e a -> e Bool) -> e [a] -> e Bool Source #

anyE :: (ConstExp e, LogicExp e, ListExp e, DinoType a) => (e a -> e Bool) -> e [a] -> e Bool Source #

find :: (LogicExp e, ListExp e, DinoType a) => (e a -> e Bool) -> e [a] -> e (Maybe a) Source #

(<++>) :: ListExpFO e => e [a] -> e [a] -> e [a] Source #

Operations on Haskell lists

and :: (ConstExp e, LogicExp e) => [e Bool] -> e Bool Source #

or :: (ConstExp e, LogicExp e) => [e Bool] -> e Bool Source #

all :: (ConstExp e, LogicExp e) => (a -> e Bool) -> [a] -> e Bool Source #

any :: (ConstExp e, LogicExp e) => (a -> e Bool) -> [a] -> e Bool Source #

Optional monad

data Optional e a where Source #

Optional expressions with a Monad instance

Optional is handy to avoid nested uses of maybe. As an example, here is a safe division function:

safeDiv :: _ => e a -> e a -> Optional e (e a)
safeDiv a b = suppose $
  if (b /= lit 0)
    then just (fdiv a b)
    else nothing

And here is a calculation that defaults to 0 if any of the divisions fails:

foo :: _ => Exp e Double -> Exp e Double -> Exp e Double
foo a b = fromOptional 0 $ do
  x <- safeDiv a b
  y <- safeDiv b x
  safeDiv x y

Constructors

Return :: a -> Optional e a 
Bind :: DinoType a => e (Maybe a) -> (e a -> Optional e b) -> Optional e b 
Instances
Monad (Optional e) Source # 
Instance details

Defined in Dino.Expression

Methods

(>>=) :: Optional e a -> (a -> Optional e b) -> Optional e b #

(>>) :: Optional e a -> Optional e b -> Optional e b #

return :: a -> Optional e a #

fail :: String -> Optional e a #

Functor (Optional e) Source # 
Instance details

Defined in Dino.Expression

Methods

fmap :: (a -> b) -> Optional e a -> Optional e b #

(<$) :: a -> Optional e b -> Optional e a #

Applicative (Optional e) Source # 
Instance details

Defined in Dino.Expression

Methods

pure :: a -> Optional e a #

(<*>) :: Optional e (a -> b) -> Optional e a -> Optional e b #

liftA2 :: (a -> b -> c) -> Optional e a -> Optional e b -> Optional e c #

(*>) :: Optional e a -> Optional e b -> Optional e b #

(<*) :: Optional e a -> Optional e b -> Optional e a #

suppose :: DinoType a => e (Maybe a) -> Optional e (e a) Source #

Lift an optional expression to Optional

optional Source #

Arguments

:: (ConstExp e, CondExp e, LetExp e, DinoType a, DinoType b) 
=> e b

Result if missing

-> (e a -> e b)

Result if present

-> Optional e (e a)

Value to examine

-> e b 

Convert from Optional value to an optional expression

runOptional :: (ConstExp e, CondExp e, LetExp e, DinoType a) => Optional e (e a) -> e (Maybe a) Source #

fromOptional Source #

Arguments

:: (ConstExp e, CondExp e, LetExp e, DinoType a) 
=> e a

Default value (in case the Optional value is missing)

-> Optional e (e a) 
-> e a 

Extract an Optional value