imperative-edsl-0.8.2: Deep embedding of imperative programs with code generation
Safe HaskellNone
LanguageHaskell2010

Language.Embedded.Imperative.CMD

Description

Imperative commands. These commands can be used with the Program monad, and different command types can be combined using (:+:).

These commands are general imperative constructs independent of the back end, except for C_CMD which is C-specific.

Synopsis

References

data Ref a Source #

Mutable reference

Constructors

RefComp VarId 
RefRun (IORef a) 

Instances

Instances details
Eq (Ref a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

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

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

ToIdent (Ref a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

toIdent :: Ref a -> SrcLoc -> Id #

Assignable (Ref a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

data RefCMD fs a where Source #

Commands for mutable references

Constructors

NewRef :: pred a => String -> RefCMD (Param3 prog exp pred) (Ref a) 
InitRef :: pred a => String -> exp a -> RefCMD (Param3 prog exp pred) (Ref a) 
GetRef :: pred a => Ref a -> RefCMD (Param3 prog exp pred) (Val a) 
SetRef :: pred a => Ref a -> exp a -> RefCMD (Param3 prog exp pred) () 
UnsafeFreezeRef :: pred a => Ref a -> RefCMD (Param3 prog exp pred) (Val a) 

Instances

Instances details
HFunctor (RefCMD :: (k -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hfmap :: forall f g (fs :: k1) (a :: k2). (forall (b :: k0). f b -> g b) -> RefCMD '(f, fs) a -> RefCMD '(g, fs) a #

(RefCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) :<: instr => Reexpressible (RefCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) (instr :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) env Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

reexpressInstrEnv :: forall (m :: Type -> Type) exp1 exp2 (fs :: k1) a. Monad m => (forall (b :: k). exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> RefCMD '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a #

InterpBi (RefCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) IO (Param1 pred :: (Type -> Constraint, Type)) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

interpBi :: forall (a :: k). RefCMD '(IO, '(IO, Param1 pred)) a -> IO a #

(CompExp exp, CompTypeClass ct) => Interp (RefCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) CGen (Param2 exp ct :: (Type -> Type, (Type -> Constraint, Type))) Source # 
Instance details

Defined in Language.Embedded.Imperative.Backend.C

Methods

interp :: forall (a :: k). RefCMD '(CGen, Param2 exp ct) a -> CGen a #

HBifunctor (RefCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hbimap :: forall f g i j (fs :: k1) (a :: k2). (Functor f, Functor g) => (forall b. f b -> g b) -> (forall (b :: k). i b -> j b) -> RefCMD '(f, '(i, fs)) a -> RefCMD '(g, '(j, fs)) a #

DryInterp (RefCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

dryInterp :: forall m (fs :: k) a. MonadSupply m => RefCMD '(m, fs) a -> m a Source #

Arrays

data Arr i a Source #

Mutable array

Constructors

ArrComp VarId 
ArrRun (IORef (IOArray i a)) 

Instances

Instances details
Eq (Arr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

(==) :: Arr i a -> Arr i a -> Bool #

(/=) :: Arr i a -> Arr i a -> Bool #

ToIdent (Arr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

toIdent :: Arr i a -> SrcLoc -> Id #

Assignable (Arr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

IsPointer (Arr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

runSwapPtr :: Arr i a -> Arr i a -> IO () Source #

data IArr i a Source #

Immutable array

Constructors

IArrComp VarId 
IArrRun (Array i a) 

Instances

Instances details
(Ix i, Show i, Show a) => Show (IArr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

showsPrec :: Int -> IArr i a -> ShowS #

show :: IArr i a -> String #

showList :: [IArr i a] -> ShowS #

ToIdent (IArr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

toIdent :: IArr i a -> SrcLoc -> Id #

Assignable (IArr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

data ArrCMD fs a where Source #

Commands for mutable arrays

Constructors

NewArr :: (pred a, Integral i, Ix i) => String -> exp i -> ArrCMD (Param3 prog exp pred) (Arr i a) 
ConstArr :: (pred a, Integral i, Ix i) => String -> [a] -> ArrCMD (Param3 prog exp pred) (Arr i a) 
GetArr :: (pred a, Integral i, Ix i) => Arr i a -> exp i -> ArrCMD (Param3 prog exp pred) (Val a) 
SetArr :: (pred a, Integral i, Ix i) => Arr i a -> exp i -> exp a -> ArrCMD (Param3 prog exp pred) () 
CopyArr :: (pred a, Integral i, Ix i) => (Arr i a, exp i) -> (Arr i a, exp i) -> exp i -> ArrCMD (Param3 prog exp pred) () 
UnsafeFreezeArr :: (pred a, Integral i, Ix i) => Arr i a -> ArrCMD (Param3 prog exp pred) (IArr i a) 
UnsafeThawArr :: (pred a, Integral i, Ix i) => IArr i a -> ArrCMD (Param3 prog exp pred) (Arr i a) 

Instances

Instances details
HFunctor (ArrCMD :: (k -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hfmap :: forall f g (fs :: k1) (a :: k2). (forall (b :: k0). f b -> g b) -> ArrCMD '(f, fs) a -> ArrCMD '(g, fs) a #

(ArrCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) :<: instr => Reexpressible (ArrCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) (instr :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) env Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

reexpressInstrEnv :: forall (m :: Type -> Type) exp1 exp2 (fs :: k1) a. Monad m => (forall (b :: k). exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> ArrCMD '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a #

InterpBi (ArrCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) IO (Param1 pred :: (Type -> Constraint, Type)) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

interpBi :: forall (a :: k). ArrCMD '(IO, '(IO, Param1 pred)) a -> IO a #

(CompExp exp, CompTypeClass ct) => Interp (ArrCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) CGen (Param2 exp ct :: (Type -> Type, (Type -> Constraint, Type))) Source # 
Instance details

Defined in Language.Embedded.Imperative.Backend.C

Methods

interp :: forall (a :: k). ArrCMD '(CGen, Param2 exp ct) a -> CGen a #

HBifunctor (ArrCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hbimap :: forall f g i j (fs :: k1) (a :: k2). (Functor f, Functor g) => (forall b. f b -> g b) -> (forall (b :: k). i b -> j b) -> ArrCMD '(f, '(i, fs)) a -> ArrCMD '(g, '(j, fs)) a #

DryInterp (ArrCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

dryInterp :: forall m (fs :: k) a. MonadSupply m => ArrCMD '(m, fs) a -> m a Source #

Control flow

data Border i Source #

Constructors

Incl i 
Excl i 

Instances

Instances details
Functor Border Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

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

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

Foldable Border Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

fold :: Monoid m => Border m -> m #

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

foldMap' :: Monoid m => (a -> m) -> Border a -> m #

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

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

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

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

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

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

toList :: Border a -> [a] #

null :: Border a -> Bool #

length :: Border a -> Int #

elem :: Eq a => a -> Border a -> Bool #

maximum :: Ord a => Border a -> a #

minimum :: Ord a => Border a -> a #

sum :: Num a => Border a -> a #

product :: Num a => Border a -> a #

Traversable Border Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

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

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

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

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

Eq i => Eq (Border i) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

(==) :: Border i -> Border i -> Bool #

(/=) :: Border i -> Border i -> Bool #

Num i => Num (Border i) Source #

fromInteger gives an inclusive border. No other methods defined.

Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

(+) :: Border i -> Border i -> Border i #

(-) :: Border i -> Border i -> Border i #

(*) :: Border i -> Border i -> Border i #

negate :: Border i -> Border i #

abs :: Border i -> Border i #

signum :: Border i -> Border i #

fromInteger :: Integer -> Border i #

Show i => Show (Border i) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

showsPrec :: Int -> Border i -> ShowS #

show :: Border i -> String #

showList :: [Border i] -> ShowS #

type IxRange i = (i, Int, Border i) Source #

Index range

(lo,step,hi)

lo gives the start index; step gives the step length; hi gives the stop index which may be inclusive or exclusive.

data ControlCMD fs a where Source #

Constructors

If :: exp Bool -> prog () -> prog () -> ControlCMD (Param3 prog exp pred) () 
While :: prog (exp Bool) -> prog () -> ControlCMD (Param3 prog exp pred) () 
For :: (pred i, Integral i) => IxRange (exp i) -> (Val i -> prog ()) -> ControlCMD (Param3 prog exp pred) () 
Break :: ControlCMD (Param3 prog exp pred) () 
Assert :: exp Bool -> String -> ControlCMD (Param3 prog exp pred) () 

Instances

Instances details
ControlCMD :<: instr => Reexpressible ControlCMD (instr :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) env Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

reexpressInstrEnv :: forall (m :: Type -> Type) exp1 exp2 (fs :: k1) a. Monad m => (forall (b :: k). exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> ControlCMD '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a #

InterpBi ControlCMD IO (Param1 pred :: (Type -> Constraint, Type)) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

interpBi :: forall (a :: k). ControlCMD '(IO, '(IO, Param1 pred)) a -> IO a #

(CompExp exp, CompTypeClass ct) => Interp ControlCMD CGen (Param2 exp ct :: (Type -> Type, (Type -> Constraint, Type))) Source # 
Instance details

Defined in Language.Embedded.Imperative.Backend.C

Methods

interp :: forall (a :: k). ControlCMD '(CGen, Param2 exp ct) a -> CGen a #

HFunctor ControlCMD Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hfmap :: forall f g (fs :: k1) (a :: k2). (forall (b :: k). f b -> g b) -> ControlCMD '(f, fs) a -> ControlCMD '(g, fs) a #

HBifunctor ControlCMD Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hbimap :: forall f g i j (fs :: k1) (a :: k2). (Functor f, Functor g) => (forall b. f b -> g b) -> (forall (b :: k). i b -> j b) -> ControlCMD '(f, '(i, fs)) a -> ControlCMD '(g, '(j, fs)) a #

DryInterp ControlCMD Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

dryInterp :: forall m (fs :: k) a. MonadSupply m => ControlCMD '(m, fs) a -> m a Source #

Generic pointer manipulation

class ToIdent a => IsPointer a where Source #

Types that are represented as a pointers in C

Methods

runSwapPtr :: a -> a -> IO () Source #

Instances

Instances details
IsPointer (Ptr a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

runSwapPtr :: Ptr a -> Ptr a -> IO () Source #

IsPointer (Arr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

runSwapPtr :: Arr i a -> Arr i a -> IO () Source #

data PtrCMD fs a where Source #

Constructors

SwapPtr :: IsPointer a => a -> a -> PtrCMD (Param3 prog exp pred) () 

Instances

Instances details
HFunctor (PtrCMD :: (k -> Type, (k1, (k2, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hfmap :: forall f g (fs :: k10) (a :: k20). (forall (b :: k0). f b -> g b) -> PtrCMD '(f, fs) a -> PtrCMD '(g, fs) a #

HBifunctor (PtrCMD :: (Type -> Type, (k -> Type, (k2, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hbimap :: forall f g i j (fs :: k1) (a :: k20). (Functor f, Functor g) => (forall b. f b -> g b) -> (forall (b :: k0). i b -> j b) -> PtrCMD '(f, '(i, fs)) a -> PtrCMD '(g, '(j, fs)) a #

(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 # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

reexpressInstrEnv :: forall (m :: Type -> Type) exp1 exp2 (fs :: k1) a. Monad m => (forall (b :: k0). exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> PtrCMD '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a #

InterpBi (PtrCMD :: (Type -> Type, (Type -> Type, (k2, Type))) -> Type -> Type) IO (Param1 pred :: (k2, Type)) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

interpBi :: forall (a :: k). PtrCMD '(IO, '(IO, Param1 pred)) a -> IO a #

Interp (PtrCMD :: (Type -> Type, (k1, (k2, Type))) -> Type -> Type) CGen (Param2 exp ct :: (k1, (k2, Type))) Source # 
Instance details

Defined in Language.Embedded.Imperative.Backend.C

Methods

interp :: forall (a :: k). PtrCMD '(CGen, Param2 exp ct) a -> CGen a #

DryInterp (PtrCMD :: (Type -> Type, (k1, (k2, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

dryInterp :: forall m (fs :: k) a. MonadSupply m => PtrCMD '(m, fs) a -> m a Source #

File handling

data Handle Source #

File handle

Instances

Instances details
Eq Handle Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

(==) :: Handle -> Handle -> Bool #

(/=) :: Handle -> Handle -> Bool #

Show Handle Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

ToIdent Handle Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

toIdent :: Handle -> SrcLoc -> Id #

stdin :: Handle Source #

Handle to stdin

stdout :: Handle Source #

Handle to stdout

data PrintfArg exp where Source #

Constructors

PrintfArg :: PrintfArg a => exp a -> PrintfArg exp 

mapPrintfArg :: (forall a. exp1 a -> exp2 a) -> PrintfArg exp1 -> PrintfArg exp2 Source #

mapPrintfArgM :: Monad m => (forall a. exp1 a -> m (exp2 a)) -> PrintfArg exp1 -> m (PrintfArg exp2) Source #

class (Typeable a, Read a, PrintfArg a) => Formattable a where Source #

Values that can be printed/scanned using printf/scanf

Minimal complete definition

formatSpecPrint

Methods

formatSpecPrint :: Proxy a -> String Source #

Format specifier for printf

formatSpecScan :: Proxy a -> String Source #

Format specifier for scanf

Instances

Instances details
Formattable Double Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Float Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Int Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Int8 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Int16 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Int32 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Int64 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Word Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Word8 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Word16 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Word32 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Formattable Word64 Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

data FileCMD fs a where Source #

Constructors

FOpen :: FilePath -> IOMode -> FileCMD (Param3 prog exp pred) Handle 
FClose :: Handle -> FileCMD (Param3 prog exp pred) () 
FEof :: Handle -> FileCMD (Param3 prog exp pred) (Val Bool) 
FPrintf :: Handle -> String -> [PrintfArg exp] -> FileCMD (Param3 prog exp pred) () 
FGet :: (pred a, Formattable a) => Handle -> FileCMD (Param3 prog exp pred) (Val a) 

Instances

Instances details
HFunctor (FileCMD :: (k -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hfmap :: forall f g (fs :: k1) (a :: k2). (forall (b :: k0). f b -> g b) -> FileCMD '(f, fs) a -> FileCMD '(g, fs) a #

(FileCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) :<: instr => Reexpressible (FileCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) (instr :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) env Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

reexpressInstrEnv :: forall (m :: Type -> Type) exp1 exp2 (fs :: k1) a. Monad m => (forall (b :: k). exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> FileCMD '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a #

InterpBi (FileCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) IO (Param1 pred :: (Type -> Constraint, Type)) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

interpBi :: forall (a :: k). FileCMD '(IO, '(IO, Param1 pred)) a -> IO a #

(CompExp exp, CompTypeClass ct, ct Bool) => Interp (FileCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) CGen (Param2 exp ct :: (Type -> Type, (Type -> Constraint, Type))) Source # 
Instance details

Defined in Language.Embedded.Imperative.Backend.C

Methods

interp :: forall (a :: k). FileCMD '(CGen, Param2 exp ct) a -> CGen a #

HBifunctor (FileCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hbimap :: forall f g i j (fs :: k1) (a :: k2). (Functor f, Functor g) => (forall b. f b -> g b) -> (forall (b :: k). i b -> j b) -> FileCMD '(f, '(i, fs)) a -> FileCMD '(g, '(j, fs)) a #

DryInterp (FileCMD :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

dryInterp :: forall m (fs :: k) a. MonadSupply m => FileCMD '(m, fs) a -> m a Source #

C-specific commands

newtype Ptr (a :: *) Source #

Pointer

Constructors

PtrComp 

Fields

Instances

Instances details
Eq (Ptr a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

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

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

Show (Ptr a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

showsPrec :: Int -> Ptr a -> ShowS #

show :: Ptr a -> String #

showList :: [Ptr a] -> ShowS #

ToIdent (Ptr a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

toIdent :: Ptr a -> SrcLoc -> Id #

Assignable (Ptr a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

IsPointer (Ptr a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

runSwapPtr :: Ptr a -> Ptr a -> IO () Source #

data Object Source #

Abstract object

Constructors

Object 

Instances

Instances details
Eq Object Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

(==) :: Object -> Object -> Bool #

(/=) :: Object -> Object -> Bool #

Show Object Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

ToIdent Object Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

toIdent :: Object -> SrcLoc -> Id #

Assignable Object Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

class Arg arg pred where Source #

Methods

mkArg :: arg pred -> CGen Exp Source #

mkParam :: arg pred -> CGen Param Source #

Instances

Instances details
Arg (ObjArg :: k -> Type) (pred :: k) Source # 
Instance details

Defined in Language.Embedded.Imperative.Args

Methods

mkArg :: ObjArg pred -> CGen Exp Source #

mkParam :: ObjArg pred -> CGen Param Source #

Arg (StrArg :: k -> Type) (pred :: k) Source # 
Instance details

Defined in Language.Embedded.Imperative.Args

Methods

mkArg :: StrArg pred -> CGen Exp Source #

mkParam :: StrArg pred -> CGen Param Source #

Arg (ConstArg :: k -> Type) (pred :: k) Source # 
Instance details

Defined in Language.Embedded.Imperative.Args

Methods

mkArg :: ConstArg pred -> CGen Exp Source #

mkParam :: ConstArg pred -> CGen Param Source #

CompTypeClass ct => Arg PtrArg (ct :: Type -> Constraint) Source # 
Instance details

Defined in Language.Embedded.Imperative.Args

CompTypeClass ct => Arg IArrArg (ct :: Type -> Constraint) Source # 
Instance details

Defined in Language.Embedded.Imperative.Args

CompTypeClass ct => Arg ArrArg (ct :: Type -> Constraint) Source # 
Instance details

Defined in Language.Embedded.Imperative.Args

CompTypeClass ct => Arg RefArg (ct :: Type -> Constraint) Source # 
Instance details

Defined in Language.Embedded.Imperative.Args

(CompExp exp, CompTypeClass ct) => Arg (FunArg exp :: (Type -> Constraint) -> Type) (ct :: Type -> Constraint) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

mkArg :: FunArg exp ct -> CGen Exp Source #

mkParam :: FunArg exp ct -> CGen Param Source #

data FunArg exp pred where Source #

Constructors

ValArg :: pred a => exp a -> FunArg exp pred 
AddrArg :: FunArg exp pred -> FunArg exp pred 
DerefArg :: FunArg exp pred -> FunArg exp pred 
OffsetArg :: FunArg exp pred -> exp i -> FunArg exp pred 
FunArg :: Arg arg pred => arg pred -> FunArg exp pred 

Instances

Instances details
(CompExp exp, CompTypeClass ct) => Arg (FunArg exp :: (Type -> Constraint) -> Type) (ct :: Type -> Constraint) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

mkArg :: FunArg exp ct -> CGen Exp Source #

mkParam :: FunArg exp ct -> CGen Param Source #

mapFunArg :: (forall a. exp1 a -> exp2 a) -> FunArg exp1 pred -> FunArg exp2 pred Source #

mapFunArgM :: Monad m => (forall a. exp1 a -> m (exp2 a)) -> FunArg exp1 pred -> m (FunArg exp2 pred) Source #

class ToIdent obj => Assignable obj Source #

Instances

Instances details
Assignable Object Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Assignable (Ptr a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Assignable (Ref a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Assignable (IArr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Assignable (Arr i a) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

data C_CMD fs a where Source #

Constructors

NewCArr :: (pred a, Integral i, Ix i) => String -> Maybe i -> exp i -> C_CMD (Param3 prog exp pred) (Arr i a) 
ConstCArr :: (pred a, Integral i, Ix i) => String -> Maybe i -> [a] -> C_CMD (Param3 prog exp pred) (Arr i a) 
NewPtr :: pred a => String -> C_CMD (Param3 prog exp pred) (Ptr a) 
PtrToArr :: Ptr a -> C_CMD (Param3 prog exp pred) (Arr i a) 
NewObject :: String -> String -> Bool -> C_CMD (Param3 prog exp pred) Object 
AddInclude :: String -> C_CMD (Param3 prog exp pred) () 
AddDefinition :: Definition -> C_CMD (Param3 prog exp pred) () 
AddExternFun :: pred res => String -> proxy res -> [FunArg exp pred] -> C_CMD (Param3 prog exp pred) () 
AddExternProc :: String -> [FunArg exp pred] -> C_CMD (Param3 prog exp pred) () 
CallFun :: pred a => String -> [FunArg exp pred] -> C_CMD (Param3 prog exp pred) (Val a) 
CallProc :: Assignable obj => Maybe obj -> String -> [FunArg exp pred] -> C_CMD (Param3 prog exp pred) () 
InModule :: String -> prog () -> C_CMD (Param3 prog exp pred) () 

Instances

Instances details
C_CMD :<: instr => Reexpressible C_CMD (instr :: (Type -> Type, (Type -> Type, (Type -> Constraint, Type))) -> Type -> Type) env Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

reexpressInstrEnv :: forall (m :: Type -> Type) exp1 exp2 (fs :: k1) a. Monad m => (forall (b :: k). exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> C_CMD '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a #

InterpBi C_CMD IO (Param1 pred :: (Type -> Constraint, Type)) Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

interpBi :: forall (a :: k). C_CMD '(IO, '(IO, Param1 pred)) a -> IO a #

(CompExp exp, CompTypeClass ct) => Interp C_CMD CGen (Param2 exp ct :: (Type -> Type, (Type -> Constraint, Type))) Source # 
Instance details

Defined in Language.Embedded.Imperative.Backend.C

Methods

interp :: forall (a :: k). C_CMD '(CGen, Param2 exp ct) a -> CGen a #

HFunctor C_CMD Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hfmap :: forall f g (fs :: k1) (a :: k2). (forall (b :: k). f b -> g b) -> C_CMD '(f, fs) a -> C_CMD '(g, fs) a #

HBifunctor C_CMD Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

hbimap :: forall f g i j (fs :: k1) (a :: k2). (Functor f, Functor g) => (forall b. f b -> g b) -> (forall (b :: k). i b -> j b) -> C_CMD '(f, '(i, fs)) a -> C_CMD '(g, '(j, fs)) a #

DryInterp C_CMD Source # 
Instance details

Defined in Language.Embedded.Imperative.CMD

Methods

dryInterp :: forall m (fs :: k) a. MonadSupply m => C_CMD '(m, fs) a -> m a Source #