Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- module Prelude.EDSL
- guard :: Alternative f => Bool -> f ()
- join :: Monad m => m (m a) -> m a
- class Applicative m => Monad (m :: Type -> Type) where
- class Functor (f :: Type -> Type) where
- class Monad m => MonadFail (m :: Type -> Type) where
- mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
- sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)
- mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a
- (<$!>) :: Monad m => (a -> b) -> m a -> m b
- unless :: Applicative f => Bool -> f () -> f ()
- replicateM_ :: Applicative m => Int -> m a -> m ()
- replicateM :: Applicative m => Int -> m a -> m [a]
- foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()
- zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()
- zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]
- mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
- forever :: Applicative f => f a -> f b
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]
- forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
- msum :: (Foldable t, MonadPlus m) => t (m a) -> m a
- sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
- forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
- mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
- void :: Functor f => f a -> f ()
- ap :: Monad m => m (a -> b) -> m a -> m b
- liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
- liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
- liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
- liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
- liftM :: Monad m => (a1 -> r) -> m a1 -> m r
- when :: Applicative f => Bool -> f () -> f ()
- (=<<) :: Monad m => (a -> m b) -> m a -> m b
- class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where
- data Data a
- class (Syntactic a, Domain a ~ FeldDomain, Type (Internal a)) => Syntax a
- data Comp a
- module Data.Int
- module Data.Word
- data Complex a = !a :+ !a
- class (Eq a, Show a, Typeable a) => PrimType' a
- class (PrimType' a, Type a) => PrimType a
- class (Eq a, Show a, Typeable a, Inhabited a) => Type a
- type Length = Word32
- type Index = Word32
- data Ref a
- type DRef a = Ref (Data a)
- data Arr a
- type DArr a = Arr (Data a)
- data IArr a
- type DIArr a = IArr (Data a)
- class Inhabited a
- class Syntactic a
- type family Domain a :: Type -> Type
- type family Internal a
- eval :: (Syntactic a, Domain a ~ FeldDomain) => a -> Internal a
- showAST :: (Syntactic a, Domain a ~ FeldDomain) => a -> String
- drawAST :: (Syntactic a, Domain a ~ FeldDomain) => a -> IO ()
- module Feldspar.Frontend
- class Eq a => Bits a
- class Bits b => FiniteBits b
- class (Real a, Enum a) => Integral a
- class Eq a => Ord a
- class (RealFrac a, Floating a) => RealFloat a
- class (Real a, Fractional a) => RealFrac a
- data Border i
- type IxRange i = (i, Int, Border i)
- data AssertionLabel
Documentation
module Prelude.EDSL
guard :: Alternative f => Bool -> f () #
Conditional failure of Alternative
computations. Defined by
guard True =pure
() guard False =empty
Examples
Common uses of guard
include conditionally signaling an error in
an error monad and conditionally rejecting the current choice in an
Alternative
-based parser.
As an example of signaling an error in the error monad Maybe
,
consider a safe division function safeDiv x y
that returns
Nothing
when the denominator y
is zero and
otherwise. For example:Just
(x `div`
y)
>>> safeDiv 4 0 Nothing >>> safeDiv 4 2 Just 2
A definition of safeDiv
using guards, but not guard
:
safeDiv :: Int -> Int -> Maybe Int safeDiv x y | y /= 0 = Just (x `div` y) | otherwise = Nothing
A definition of safeDiv
using guard
and Monad
do
-notation:
safeDiv :: Int -> Int -> Maybe Int safeDiv x y = do guard (y /= 0) return (x `div` y)
join :: Monad m => m (m a) -> m a #
The join
function is the conventional monad join operator. It
is used to remove one level of monadic structure, projecting its
bound argument into the outer level.
'
' can be understood as the join
bssdo
expression
do bs <- bss bs
Examples
A common use of join
is to run an IO
computation returned from
an STM
transaction, since STM
transactions
can't perform IO
directly. Recall that
atomically
:: STM a -> IO a
is used to run STM
transactions atomically. So, by
specializing the types of atomically
and join
to
atomically
:: STM (IO b) -> IO (IO b)join
:: IO (IO b) -> IO b
we can compose them as
join
.atomically
:: STM (IO b) -> IO b
class Applicative m => Monad (m :: Type -> Type) where #
The Monad
class defines the basic operations over a monad,
a concept from a branch of mathematics known as category theory.
From the perspective of a Haskell programmer, however, it is best to
think of a monad as an abstract datatype of actions.
Haskell's do
expressions provide a convenient syntax for writing
monadic expressions.
Instances of Monad
should satisfy the following:
- Left identity
return
a>>=
k = k a- Right identity
m
>>=
return
= m- Associativity
m
>>=
(\x -> k x>>=
h) = (m>>=
k)>>=
h
Furthermore, the Monad
and Applicative
operations should relate as follows:
The above laws imply:
and that pure
and (<*>
) satisfy the applicative functor laws.
The instances of Monad
for lists, Maybe
and IO
defined in the Prelude satisfy these laws.
(>>=) :: m a -> (a -> m b) -> m b infixl 1 #
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
'as
' can be understood as the >>=
bsdo
expression
do a <- as bs a
(>>) :: m a -> m b -> m b infixl 1 #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
'as
' can be understood as the >>
bsdo
expression
do as bs
Inject a value into the monadic type.
Instances
Monad [] | Since: base-2.1 |
Monad Maybe | Since: base-2.1 |
Monad IO | Since: base-2.1 |
Monad Par1 | Since: base-4.9.0.0 |
Monad Q | |
Monad Complex | Since: base-4.9.0.0 |
Monad Min | Since: base-4.9.0.0 |
Monad Max | Since: base-4.9.0.0 |
Monad First | Since: base-4.9.0.0 |
Monad Last | Since: base-4.9.0.0 |
Monad Option | Since: base-4.9.0.0 |
Monad Identity | Since: base-4.8.0.0 |
Monad First | Since: base-4.8.0.0 |
Monad Last | Since: base-4.8.0.0 |
Monad Dual | Since: base-4.8.0.0 |
Monad Sum | Since: base-4.8.0.0 |
Monad Product | Since: base-4.8.0.0 |
Monad ReadP | Since: base-2.1 |
Monad NonEmpty | Since: base-4.9.0.0 |
Monad Tree | |
Monad Seq | |
Monad SmallArray | |
Defined in Data.Primitive.SmallArray (>>=) :: SmallArray a -> (a -> SmallArray b) -> SmallArray b # (>>) :: SmallArray a -> SmallArray b -> SmallArray b # return :: a -> SmallArray a # | |
Monad Array | |
Monad Vector | |
Monad Id | |
Monad Box | |
Monad P | Since: base-2.1 |
Monad Comp Source # | |
Monad Run Source # | |
Monad Parser Source # | |
Monad Validated Source # | |
() :=> (Monad ((->) a :: Type -> Type)) | |
Defined in Data.Constraint | |
() :=> (Monad []) | |
Defined in Data.Constraint | |
() :=> (Monad IO) | |
() :=> (Monad (Either a)) | |
() :=> (Monad Identity) | |
Monad (Either e) | Since: base-4.4.0.0 |
Monad (U1 :: Type -> Type) | Since: base-4.9.0.0 |
Monoid a => Monad ((,) a) | Since: base-4.9.0.0 |
Monad m => Monad (WrappedMonad m) | Since: base-4.7.0.0 |
Defined in Control.Applicative (>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b # (>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # return :: a -> WrappedMonad m a # | |
ArrowApply a => Monad (ArrowMonad a) | Since: base-2.1 |
Defined in Control.Arrow (>>=) :: ArrowMonad a a0 -> (a0 -> ArrowMonad a b) -> ArrowMonad a b # (>>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b # return :: a0 -> ArrowMonad a a0 # | |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Monad m => Monad (ExceptionT m) | |
Defined in Control.Monad.Exception (>>=) :: ExceptionT m a -> (a -> ExceptionT m b) -> ExceptionT m b # (>>) :: ExceptionT m a -> ExceptionT m b -> ExceptionT m b # return :: a -> ExceptionT m a # | |
Monad t => Monad (CGenT t) | |
Monad m => Monad (ListT m) | |
Monad m => Monad (MaybeT m) | |
Monad m => Monad (OptionT m) Source # | |
Class (Applicative f) (Monad f) | |
Defined in Data.Constraint cls :: Monad f :- Applicative f # | |
(Monad m) :=> (Functor (WrappedMonad m)) | |
Defined in Data.Constraint | |
(Monad m) :=> (Applicative (WrappedMonad m)) | |
Defined in Data.Constraint ins :: Monad m :- Applicative (WrappedMonad m) # | |
Monad f => Monad (Rec1 f) | Since: base-4.9.0.0 |
(Monoid a, Monoid b) => Monad ((,,) a b) | Since: base-4.14.0.0 |
Monad m => Monad (Kleisli m a) | Since: base-4.14.0.0 |
Monad f => Monad (Ap f) | Since: base-4.12.0.0 |
Monad f => Monad (Alt f) | Since: base-4.8.0.0 |
(Applicative f, Monad f) => Monad (WhenMissing f x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal (>>=) :: WhenMissing f x a -> (a -> WhenMissing f x b) -> WhenMissing f x b # (>>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b # return :: a -> WhenMissing f x a # | |
Monad m => Monad (StateT s m) | |
Monad m => Monad (ReaderT r m) | |
Monad m => Monad (IdentityT m) | |
(Monad m, Error e) => Monad (ErrorT e m) | |
Monad m => Monad (ExceptT e m) | |
Monad m => Monad (StateT s m) | |
(Monoid w, Monad m) => Monad (WriterT w m) | |
(Monoid w, Monad m) => Monad (WriterT w m) | |
Monad (Remon dom m) | |
Class (Monad f, Alternative f) (MonadPlus f) | |
Defined in Data.Constraint | |
Monad ((->) r :: Type -> Type) | Since: base-2.1 |
(Monad f, Monad g) => Monad (f :*: g) | Since: base-4.9.0.0 |
(Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c) | Since: base-4.14.0.0 |
(Monad f, Monad g) => Monad (Product f g) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Monad (WhenMatched f x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.IntMap.Internal (>>=) :: WhenMatched f x y a -> (a -> WhenMatched f x y b) -> WhenMatched f x y b # (>>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b # return :: a -> WhenMatched f x y a # | |
(Applicative f, Monad f) => Monad (WhenMissing f k x) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal (>>=) :: WhenMissing f k x a -> (a -> WhenMissing f k x b) -> WhenMissing f k x b # (>>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b # return :: a -> WhenMissing f k x a # | |
Monad (ContT r m) | |
Monad f => Monad (M1 i c f) | Since: base-4.9.0.0 |
(Monad f, Applicative f) => Monad (WhenMatched f k x y) | Equivalent to Since: containers-0.5.9 |
Defined in Data.Map.Internal (>>=) :: WhenMatched f k x y a -> (a -> WhenMatched f k x y b) -> WhenMatched f k x y b # (>>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b # return :: a -> WhenMatched f k x y a # | |
Monad m => Monad (ProgramT instr fs m) | |
(Monoid w, Monad m) => Monad (RWST r w s m) | |
(Monoid w, Monad m) => Monad (RWST r w s m) | |
class Functor (f :: Type -> Type) where #
A type f
is a Functor if it provides a function fmap
which, given any types a
and b
lets you apply any function from (a -> b)
to turn an f a
into an f b
, preserving the
structure of f
. Furthermore f
needs to adhere to the following:
Note, that the second law follows from the free theorem of the type fmap
and
the first law, so you need only check that the former condition holds.
fmap :: (a -> b) -> f a -> f b #
Using ApplicativeDo
: '
' can be understood as
the fmap
f asdo
expression
do a <- as pure (f a)
with an inferred Functor
constraint.
Instances
class Monad m => MonadFail (m :: Type -> Type) where #
When a value is bound in do
-notation, the pattern on the left
hand side of <-
might not match. In this case, this class
provides a function to recover.
A Monad
without a MonadFail
instance may only be used in conjunction
with pattern that always match, such as newtypes, tuples, data types with
only a single data constructor, and irrefutable patterns (~pat
).
Instances of MonadFail
should satisfy the following law: fail s
should
be a left zero for >>=
,
fail s >>= f = fail s
If your Monad
is also MonadPlus
, a popular definition is
fail _ = mzero
Since: base-4.9.0.0
Instances
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) #
Map each element of a structure to a monadic action, evaluate
these actions from left to right, and collect the results. For
a version that ignores the results see mapM_
.
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) #
Evaluate each monadic action in the structure from left to
right, and collect the results. For a version that ignores the
results see sequence_
.
unless :: Applicative f => Bool -> f () -> f () #
The reverse of when
.
replicateM_ :: Applicative m => Int -> m a -> m () #
Like replicateM
, but discards the result.
replicateM :: Applicative m => Int -> m a -> m [a] #
performs the action replicateM
n actn
times,
gathering the results.
Using ApplicativeDo
: '
' can be understood as
the replicateM
5 asdo
expression
do a1 <- as a2 <- as a3 <- as a4 <- as a5 <- as pure [a1,a2,a3,a4,a5]
Note the Applicative
constraint.
foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m () #
Like foldM
, but discards the result.
zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m () #
zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c] #
mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c]) #
The mapAndUnzipM
function maps its first argument over a list, returning
the result as a pair of lists. This function is mainly used with complicated
data structures or a state monad.
forever :: Applicative f => f a -> f b #
Repeat an action indefinitely.
Using ApplicativeDo
: '
' can be understood as the
pseudo-forever
asdo
expression
do as as ..
with as
repeating.
Examples
A common use of forever
is to process input from network sockets,
Handle
s, and channels
(e.g. MVar
and
Chan
).
For example, here is how we might implement an echo
server, using
forever
both to listen for client connections on a network socket
and to echo client input on client connection handles:
echoServer :: Socket -> IO () echoServer socket =forever
$ do client <- accept socketforkFinally
(echo client) (\_ -> hClose client) where echo :: Handle -> IO () echo client =forever
$ hGetLine client >>= hPutStrLn client
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #
Left-to-right composition of Kleisli arrows.
'(bs
' can be understood as the >=>
cs) ado
expression
do b <- bs a cs b
filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a] #
This generalizes the list-based filter
function.
forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) #
sequence_ :: (Foldable t, Monad m) => t (m a) -> m () #
Evaluate each monadic action in the structure from left to right,
and ignore the results. For a version that doesn't ignore the
results see sequence
.
As of base 4.8.0.0, sequence_
is just sequenceA_
, specialized
to Monad
.
void :: Functor f => f a -> f () #
discards or ignores the result of evaluation, such
as the return value of an void
valueIO
action.
Using ApplicativeDo
: '
' can be understood as the
void
asdo
expression
do as pure ()
with an inferred Functor
constraint.
Examples
Replace the contents of a
with unit:Maybe
Int
>>>
void Nothing
Nothing>>>
void (Just 3)
Just ()
Replace the contents of an
with unit, resulting in an Either
Int
Int
:Either
Int
()
>>>
void (Left 8675309)
Left 8675309>>>
void (Right 8675309)
Right ()
Replace every element of a list with unit:
>>>
void [1,2,3]
[(),(),()]
Replace the second element of a pair with unit:
>>>
void (1,2)
(1,())
Discard the result of an IO
action:
>>>
mapM print [1,2]
1 2 [(),()]>>>
void $ mapM print [1,2]
1 2
liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r #
Promote a function to a monad, scanning the monadic arguments from
left to right (cf. liftM2
).
liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r #
Promote a function to a monad, scanning the monadic arguments from
left to right (cf. liftM2
).
liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r #
Promote a function to a monad, scanning the monadic arguments from
left to right (cf. liftM2
).
liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r #
Promote a function to a monad, scanning the monadic arguments from left to right. For example,
liftM2 (+) [0,1] [0,2] = [0,2,1,3] liftM2 (+) (Just 1) Nothing = Nothing
when :: Applicative f => Bool -> f () -> f () #
Conditional execution of Applicative
expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging
if the Boolean value debug
is True
, and otherwise do nothing.
(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 #
Same as >>=
, but with the arguments interchanged.
class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type) where #
Monads that also support choice and failure.
Nothing
The identity of mplus
. It should also satisfy the equations
mzero >>= f = mzero v >> mzero = mzero
The default definition is
mzero = empty
An associative operation. The default definition is
mplus = (<|>
)
Instances
Types
Syntax
Instances
class (Syntactic a, Domain a ~ FeldDomain, Type (Internal a)) => Syntax a Source #
Specialization of the Syntactic
class for the Feldspar domain
Instances
(Syntactic a, Domain a ~ FeldDomain, Type (Internal a)) => Syntax a Source # | |
Defined in Feldspar.Representation |
Monad for computational effects: mutable data structures and control flow
Instances
Monad Comp Source # | |
Functor Comp Source # | |
Applicative Comp Source # | |
MonadComp Comp Source # | |
MonadRun Comp Source # | |
Syntax a => Storable (Push Comp a) Source # | |
Defined in Feldspar.Data.Storable newStoreRep :: MonadComp m => proxy (Push Comp a) -> StoreSize (Push Comp a) -> m (StoreRep (Push Comp a)) Source # initStoreRep :: MonadComp m => Push Comp a -> m (StoreRep (Push Comp a)) Source # readStoreRep :: MonadComp m => StoreRep (Push Comp a) -> m (Push Comp a) Source # unsafeFreezeStoreRep :: MonadComp m => StoreRep (Push Comp a) -> m (Push Comp a) Source # writeStoreRep :: MonadComp m => StoreRep (Push Comp a) -> Push Comp a -> m () Source # | |
type StoreRep (Push Comp a) Source # | |
type StoreSize (Push Comp a) Source # | |
Object-language types
module Data.Int
module Data.Word
Complex numbers are an algebraic type.
For a complex number z
,
is a number with the magnitude of abs
zz
,
but oriented in the positive real direction, whereas
has the phase of signum
zz
, but unit magnitude.
The Foldable
and Traversable
instances traverse the real part first.
Note that Complex
's instances inherit the deficiencies from the type
parameter's. For example, Complex Float
's Ord
instance has similar
problems to Float
's.
!a :+ !a infix 6 | forms a complex number from its real and imaginary rectangular components. |
Instances
class (Eq a, Show a, Typeable a) => PrimType' a Source #
Primitive supported types
Instances
class (Eq a, Show a, Typeable a, Inhabited a) => Type a Source #
Supported types
Instances
Type Bool Source # | |
Type Double Source # | |
Type Float Source # | |
Type Int8 Source # | |
Type Int16 Source # | |
Type Int32 Source # | |
Type Int64 Source # | |
Type Word8 Source # | |
Type Word16 Source # | |
Type Word32 Source # | |
Type Word64 Source # | |
Type (Complex Double) Source # | |
Type (Complex Float) Source # | |
(Type a, Type b) => Type (a, b) Source # | |
Defined in Feldspar.Representation |
Mutable variable
Mutable array
Instances
Eq (Arr a) Source # |
|
Slicable (Arr a) Source # | |
Finite (Arr a) Source # | |
(MarshalHaskell (Internal a), MarshalFeld a, Syntax a) => MarshalFeld (Arr a) Source # | |
(Syntax a, BulkTransferable a, ContainerType a ~ Arr a) => Transferable (Arr a) Source # | |
Defined in Feldspar.Data.Vector calcChanSize :: proxy (Arr a) -> SizeSpec (Arr a) -> ChanSize Data PrimType' Length Source # newChan :: SizeSpec (Arr a) -> Run (Chan Uncloseable (Arr a)) Source # newCloseableChan :: SizeSpec (Arr a) -> Run (Chan Closeable (Arr a)) Source # readChan :: Chan t (Arr a) -> Run (Arr a) Source # untypedReadChan :: Chan t c -> Run (Arr a) Source # writeChan :: Chan t (Arr a) -> Arr a -> Run (Data Bool) Source # untypedWriteChan :: Chan t c -> Arr a -> Run (Data Bool) Source # | |
type HaskellRep (Arr a) Source # | |
Defined in Feldspar.Run.Marshal | |
type SizeSpec (Arr a) Source # | |
Defined in Feldspar.Data.Vector |
Immutable array
Instances
Inhabited types
Instances
Instances
type family Domain a :: Type -> Type #
Instances
type Domain () Source # | |
Defined in Feldspar.Frontend | |
type Domain (Prim a) Source # | |
Defined in Feldspar.Primitive.Representation | |
type Domain (Data a) Source # | |
Defined in Feldspar.Representation | |
type Domain (Validated a) Source # | |
Defined in Feldspar.Data.Validated | |
type Domain (Option a) Source # | |
Defined in Feldspar.Data.Option | |
type Domain (a -> b) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b) Source # | |
Defined in Feldspar.Sugar | |
type Domain (ASTF sym a) | |
Defined in Language.Syntactic.Sugar | |
type Domain (ASTFull sym a) | |
Defined in Language.Syntactic.Sugar | |
type Domain (a, b, c) Source # | |
Defined in Feldspar.Sugar | |
type Domain (Struct PrimType' Data a) Source # | |
Defined in Feldspar.Representation | |
type Domain (a, b, c, d) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h, i) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h, i, j) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h, i, j, k) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h, i, j, k, l) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | |
Defined in Feldspar.Sugar | |
type Domain (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | |
Defined in Feldspar.Sugar |
Instances
type Internal () Source # | |
Defined in Feldspar.Frontend | |
type Internal (Prim a) Source # | |
Defined in Feldspar.Primitive.Representation | |
type Internal (Data a) Source # | |
Defined in Feldspar.Representation | |
type Internal (Validated a) Source # | |
Defined in Feldspar.Data.Validated | |
type Internal (Option a) Source # | |
Defined in Feldspar.Data.Option | |
type Internal (a -> b) Source # | |
Defined in Feldspar.Sugar | |
type Internal (a, b) Source # | |
Defined in Feldspar.Sugar | |
type Internal (ASTF sym a) | |
Defined in Language.Syntactic.Sugar | |
type Internal (ASTFull sym a) | |
Defined in Language.Syntactic.Sugar | |
type Internal (a, b, c) Source # | |
Defined in Feldspar.Sugar | |
type Internal (Struct PrimType' Data a) Source # | |
Defined in Feldspar.Representation | |
type Internal (a, b, c, d) Source # | |
type Internal (a, b, c, d, e) Source # | |
type Internal (a, b, c, d, e, f) Source # | |
type Internal (a, b, c, d, e, f, g) Source # | |
type Internal (a, b, c, d, e, f, g, h) Source # | |
type Internal (a, b, c, d, e, f, g, h, i) Source # | |
type Internal (a, b, c, d, e, f, g, h, i, j) Source # | |
type Internal (a, b, c, d, e, f, g, h, i, j, k) Source # | |
type Internal (a, b, c, d, e, f, g, h, i, j, k, l) Source # | |
type Internal (a, b, c, d, e, f, g, h, i, j, k, l, m) Source # | |
type Internal (a, b, c, d, e, f, g, h, i, j, k, l, m, n) Source # | |
type Internal (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) Source # | |
Front end
eval :: (Syntactic a, Domain a ~ FeldDomain) => a -> Internal a Source #
Evaluate a closed expression
showAST :: (Syntactic a, Domain a ~ FeldDomain) => a -> String Source #
Show the syntax tree using Unicode art
Only user assertions will be included.
drawAST :: (Syntactic a, Domain a ~ FeldDomain) => a -> IO () Source #
Draw the syntax tree on the terminal using Unicode art
Only user assertions will be included.
module Feldspar.Frontend
The Bits
class defines bitwise operations over integral types.
- Bits are numbered from 0 with bit 0 being the least significant bit.
(.&.), (.|.), xor, complement, (shift | shiftL, shiftR), (rotate | rotateL, rotateR), bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount
Instances
class Bits b => FiniteBits b #
The FiniteBits
class denotes types with a finite, fixed number of bits.
Since: base-4.7.0.0
Instances
class (Real a, Enum a) => Integral a #
Integral numbers, supporting integer division.
The Haskell Report defines no laws for Integral
. However, Integral
instances are customarily expected to define a Euclidean domain and have the
following properties for the div
/mod
and quot
/rem
pairs, given
suitable Euclidean functions f
and g
:
x
=y * quot x y + rem x y
withrem x y
=fromInteger 0
org (rem x y)
<g y
x
=y * div x y + mod x y
withmod x y
=fromInteger 0
orf (mod x y)
<f y
An example of a suitable Euclidean function, for Integer
's instance, is
abs
.
Instances
The Ord
class is used for totally ordered datatypes.
Instances of Ord
can be derived for any user-defined datatype whose
constituent types are in Ord
. The declared order of the constructors in
the data declaration determines the ordering in derived Ord
instances. The
Ordering
datatype allows a single comparison to determine the precise
ordering of two objects.
The Haskell Report defines no laws for Ord
. However, <=
is customarily
expected to implement a non-strict partial order and have the following
properties:
- Transitivity
- if
x <= y && y <= z
=True
, thenx <= z
=True
- Reflexivity
x <= x
=True
- Antisymmetry
- if
x <= y && y <= x
=True
, thenx == y
=True
Note that the following operator interactions are expected to hold:
x >= y
=y <= x
x < y
=x <= y && x /= y
x > y
=y < x
x < y
=compare x y == LT
x > y
=compare x y == GT
x == y
=compare x y == EQ
min x y == if x <= y then x else y
=True
max x y == if x >= y then x else y
=True
Note that (7.) and (8.) do not require min
and max
to return either of
their arguments. The result is merely required to equal one of the
arguments in terms of (==)
.
Minimal complete definition: either compare
or <=
.
Using compare
can be more efficient for complex types.
Instances
class (RealFrac a, Floating a) => RealFloat a #
Efficient, machine-independent access to the components of a floating-point number.
floatRadix, floatDigits, floatRange, decodeFloat, encodeFloat, isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE
Instances
class (Real a, Fractional a) => RealFrac a #
Extracting components of fractions.
Instances
() :=> (RealFrac Double) | |
() :=> (RealFrac Float) | |
Integral a => RealFrac (Ratio a) | Since: base-2.0.1 |
RealFrac a => RealFrac (Identity a) | Since: base-4.9.0.0 |
(Integral a) :=> (RealFrac (Ratio a)) | |
(RealFrac a) :=> (RealFrac (Identity a)) | |
(RealFrac a) :=> (RealFrac (Const a b)) | |
Class (Real a, Fractional a) (RealFrac a) | |
Defined in Data.Constraint | |
Class (RealFrac a, Floating a) (RealFloat a) | |
RealFrac a => RealFrac (Const a b) | Since: base-4.9.0.0 |
Instances
Functor Border | |
Foldable Border | |
Defined in Language.Embedded.Imperative.CMD 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 # elem :: Eq a => a -> Border a -> Bool # maximum :: Ord a => Border a -> a # minimum :: Ord a => Border a -> a # | |
Traversable Border | |
Eq i => Eq (Border i) | |
Num i => Num (Border i) |
|
Show i => Show (Border i) | |
type IxRange i = (i, Int, Border i) #
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 AssertionLabel Source #
Assertion labels
InternalAssertion | Internal assertion to guarantee meaningful results |
LibraryAssertion String | Assertion related to a specific library |
UserAssertion String | Assertion in user code. The default label for user assertions is
|
Instances
Eq AssertionLabel Source # | |
Defined in Feldspar.Representation (==) :: AssertionLabel -> AssertionLabel -> Bool # (/=) :: AssertionLabel -> AssertionLabel -> Bool # | |
Show AssertionLabel Source # | |
Defined in Feldspar.Representation showsPrec :: Int -> AssertionLabel -> ShowS # show :: AssertionLabel -> String # showList :: [AssertionLabel] -> ShowS # |