Safe Haskell | None |
---|---|
Language | Haskell2010 |
Deep embedding of imperative programs with code generation. This is the main module for users who want to write imperative programs.
The Program
type is parameterized by an instruction set that can be
combined in a modular way; e.g:
type MyProg exp a =Program
(RefCMD
exp:+:
FileCMD
exp) a
Also, instructions are parameterized on the expression language.
Some examples of using the library are found in the examples
directory.
Synopsis
- module Control.Monad
- data ProgramT (instr :: (Type -> Type, k) -> Type -> Type) (fs :: k) (m :: Type -> Type) a
- type Program (instr :: (Type -> Type, k) -> Type -> Type) (fs :: k) = ProgramT instr fs Identity
- interpretT :: forall k (i :: (Type -> Type, k) -> Type -> Type) m (fs :: k) n a. (Interp i m fs, HFunctor i, Monad m) => (forall b. n b -> m b) -> ProgramT i fs n a -> m a
- interpret :: forall k (i :: (Type -> Type, k) -> Type -> Type) m (fs :: k) a. (Interp i m fs, HFunctor i, Monad m) => Program i fs a -> m a
- interpretBiT :: forall k (i :: (Type -> Type, (Type -> Type, k)) -> Type -> Type) m (fs :: k) n exp a. (InterpBi i m fs, HBifunctor i, Functor m, Monad m, Monad n) => (forall b. exp b -> m b) -> (forall b. n b -> m b) -> ProgramT i '(exp, fs) n a -> m a
- interpretBi :: forall k (i :: (Type -> Type, (Type -> Type, k)) -> Type -> Type) m (fs :: k) exp a. (InterpBi i m fs, HBifunctor i, Functor m, Monad m) => (forall b. exp b -> m b) -> Program i '(exp, fs) a -> m a
- type Param1 (a :: k) = '(a, Param0)
- type Param2 (a :: k) (b :: k1) = '(a, Param1 b)
- type Param3 (a :: k) (b :: k1) (c :: k2) = '(a, Param2 b c)
- data RefCMD fs a
- data ArrCMD fs a
- data ControlCMD fs a
- data PtrCMD fs a
- data FileCMD fs a
- data C_CMD fs a
- data ((h1 :: k -> k1 -> Type) :+: (h2 :: k -> k1 -> Type)) (fs :: k) (a :: k1)
- class (sub :: k -> k1 -> Type) :<: (sup :: k -> k1 -> Type)
- class FreeExp exp
- type family FreePred exp :: * -> Constraint
- class FreeExp exp => EvalExp exp
- class FreeExp exp => CompExp exp
- module Data.Int
- module Data.Word
- module Language.Embedded.Imperative.Frontend.General
- module Language.Embedded.Imperative.Frontend
Program monad
module Control.Monad
data ProgramT (instr :: (Type -> Type, k) -> Type -> Type) (fs :: k) (m :: Type -> Type) a #
Representation of programs parameterized by the primitive instructions (transformer version)
Instances
MonadTrans (ProgramT instr fs) | |
Defined in Control.Monad.Operational.Higher | |
Monad m => Monad (ProgramT instr fs m) | |
Monad m => Functor (ProgramT instr fs m) | |
Monad m => Applicative (ProgramT instr fs m) | |
Defined in Control.Monad.Operational.Higher pure :: a -> ProgramT instr fs m a # (<*>) :: ProgramT instr fs m (a -> b) -> ProgramT instr fs m a -> ProgramT instr fs m b # liftA2 :: (a -> b -> c) -> ProgramT instr fs m a -> ProgramT instr fs m b -> ProgramT instr fs m c # (*>) :: ProgramT instr fs m a -> ProgramT instr fs m b -> ProgramT instr fs m b # (<*) :: ProgramT instr fs m a -> ProgramT instr fs m b -> ProgramT instr fs m a # | |
((FileCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) :<: instr, a ~ ()) => PrintfType (ProgramT instr (Param2 exp pred) m a) Source # | |
type PrintfExp (ProgramT instr (Param2 exp pred) m a) Source # | |
Defined in Language.Embedded.Imperative.Frontend |
type Program (instr :: (Type -> Type, k) -> Type -> Type) (fs :: k) = ProgramT instr fs Identity #
Representation of programs parameterized by the primitive instructions
:: forall k (i :: (Type -> Type, k) -> Type -> Type) m (fs :: k) n a. (Interp i m fs, HFunctor i, Monad m) | |
=> (forall b. n b -> m b) | Interpretation of the underlying monad |
-> ProgramT i fs n a | |
-> m a |
Interpret a program in a monad. The interpretation of instructions is
provided by the Interp
class.
interpret :: forall k (i :: (Type -> Type, k) -> Type -> Type) m (fs :: k) a. (Interp i m fs, HFunctor i, Monad m) => Program i fs a -> m a #
Interpret a program in a monad. The interpretation of instructions is
provided by the Interp
class.
:: forall k (i :: (Type -> Type, (Type -> Type, k)) -> Type -> Type) m (fs :: k) n exp a. (InterpBi i m fs, HBifunctor i, Functor m, Monad m, Monad n) | |
=> (forall b. exp b -> m b) | Interpretation of the |
-> (forall b. n b -> m b) | Interpretation of the underlying monad |
-> ProgramT i '(exp, fs) n a | |
-> m a |
Interpret a program in a monad. The interpretation of instructions is
provided by the InterpBi
class.
:: forall k (i :: (Type -> Type, (Type -> Type, k)) -> Type -> Type) m (fs :: k) exp a. (InterpBi i m fs, HBifunctor i, Functor m, Monad m) | |
=> (forall b. exp b -> m b) | Interpretation of the |
-> Program i '(exp, fs) a | |
-> m a |
Interpret a program in a monad. The interpretation of instructions is
provided by the InterpBi
class.
Imperative instructions
Commands for mutable references
Instances
Commands for mutable arrays
Instances
data ControlCMD fs a Source #
Instances
Instances
HFunctor (PtrCMD :: (k -> Type, (k1, (k2, Type))) -> Type -> Type) Source # | |
Defined in Language.Embedded.Imperative.CMD | |
HBifunctor (PtrCMD :: (Type -> Type, (k -> Type, (k2, Type))) -> Type -> Type) Source # | |
(PtrCMD :: (Type -> Type, (k -> Type, (k2, Type))) -> Type -> Type) :<: instr => Reexpressible (PtrCMD :: (Type -> Type, (k -> Type, (k2, Type))) -> Type -> Type) (instr :: (Type -> Type, (k -> Type, (k2, Type))) -> Type -> Type) env Source # | |
Defined in Language.Embedded.Imperative.CMD | |
InterpBi (PtrCMD :: (Type -> Type, (Type -> Type, (k2, Type))) -> Type -> Type) IO (Param1 pred :: (k2, Type)) Source # | |
Interp (PtrCMD :: (Type -> Type, (k1, (k2, Type))) -> Type -> Type) CGen (Param2 exp ct :: (k1, (k2, Type))) Source # | |
DryInterp (PtrCMD :: (Type -> Type, (k1, (k2, Type))) -> Type -> Type) Source # | |
Defined in Language.Embedded.Imperative.CMD dryInterp :: forall m (fs :: k) a. MonadSupply m => PtrCMD '(m, fs) a -> m a Source # |
Instances
Instances
C_CMD :<: instr => Reexpressible C_CMD (instr :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) env Source # | |
Defined in Language.Embedded.Imperative.CMD | |
InterpBi C_CMD IO (Param1 pred :: (Type -> Constraint, Type)) Source # | |
(CompExp exp, CompTypeClass ct) => Interp C_CMD CGen (Param2 exp ct :: (Type -> Type, (Type -> Constraint, Type))) Source # | |
HFunctor C_CMD Source # | |
Defined in Language.Embedded.Imperative.CMD | |
HBifunctor C_CMD Source # | |
DryInterp C_CMD Source # | |
Defined in Language.Embedded.Imperative.CMD dryInterp :: forall m (fs :: k) a. MonadSupply m => C_CMD '(m, fs) a -> m a Source # |
Composing instruction sets
data ((h1 :: k -> k1 -> Type) :+: (h2 :: k -> k1 -> Type)) (fs :: k) (a :: k1) infixr 9 #
Coproducts
Instances
(f :: k1 -> k2 -> Type) :<: (f :+: g :: k1 -> k2 -> Type) | |
f :<: h => (f :: k1 -> k2 -> Type) :<: (g :+: h :: k1 -> k2 -> Type) | |
(HFunctor h1, HFunctor h2) => HFunctor (h1 :+: h2 :: (k1 -> Type, k2) -> k3 -> Type) | |
Defined in Data.ALaCarte | |
(HBifunctor h1, HBifunctor h2) => HBifunctor (h1 :+: h2 :: (Type -> Type, (k1 -> Type, k2)) -> k3 -> Type) | |
(Interp i1 m fs, Interp i2 m fs) => Interp (i1 :+: i2 :: (k1 -> Type, k2) -> k1 -> Type) (m :: k1 -> Type) (fs :: k2) | |
Defined in Control.Monad.Operational.Higher | |
(InterpBi i1 m fs, InterpBi i2 m fs) => InterpBi (i1 :+: i2 :: (k1 -> Type, (k1 -> Type, k2)) -> k1 -> Type) (m :: k1 -> Type) (fs :: k2) | |
Defined in Control.Monad.Operational.Higher | |
(Reexpressible i1 instr env, Reexpressible i2 instr env) => Reexpressible (i1 :+: i2 :: (Type -> Type, (k1 -> Type, k2)) -> Type -> Type) (instr :: (Type -> Type, (k1 -> Type, k2)) -> Type -> Type) env | |
Defined in Control.Monad.Operational.Higher | |
(DryInterp i1, DryInterp i2) => DryInterp (i1 :+: i2 :: (Type -> Type, k) -> Type -> Type) Source # | |
Defined in Language.Embedded.Traversal dryInterp :: forall m (fs :: k0) a. MonadSupply m => (i1 :+: i2) '(m, fs) a -> m a Source # | |
(Functor (h1 fs), Functor (h2 fs)) => Functor ((h1 :+: h2) fs) | |
class (sub :: k -> k1 -> Type) :<: (sup :: k -> k1 -> Type) #
A constraint f
expresses that the signature :<:
gf
is subsumed by
g
, i.e. f
can be used to construct elements in g
.
Interface for expression types
Expressions that support injection of constants and named variables
type family FreePred exp :: * -> Constraint Source #
Constraint on the types of constants and variables in an expression language
Front end
module Data.Int
module Data.Word