Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
It is occasionally useful to define generic functions that can not only compute their result as an integer, but also as a symbolic expression in the form of an AST.
There are some Haskell hacks for this - it is for example not hard
to define an instance of Num
that constructs an AST. However,
this falls down for some other interesting classes, like
Integral
, which requires both the problematic method
fromInteger
, and also that the type is an instance of Enum
.
We can always just define hobbled instances that call error
for
those methods that are impractical, but this is ugly.
Hence, this module defines similes to standard Haskell numeric typeclasses that have been modified to make generic functions slightly easier to write.
Documentation
class Num e => IntegralExp e where Source #
A twist on the Integral
type class that is more friendly to
symbolic representations.
Instances
Integral a => IntegralExp (Wrapped a) Source # | |
Defined in Futhark.Util.IntegralExp | |
(IntExp t, Pretty v) => IntegralExp (TPrimExp t v) Source # | |
Defined in Futhark.Analysis.PrimExp quot :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # rem :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # div :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # mod :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # sgn :: TPrimExp t v -> Maybe Int Source # pow :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # divUp :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # | |
IntegralExp e => IntegralExp (Count u e) Source # | |
Defined in Futhark.IR.GPU.Sizes |
This wrapper allows you to use a type that is an instance of the true class whenever the simile class is required.
Wrapped | |
|
Instances
Enum a => Enum (Wrapped a) Source # | |
Defined in Futhark.Util.IntegralExp succ :: Wrapped a -> Wrapped a # pred :: Wrapped a -> Wrapped a # fromEnum :: Wrapped a -> Int # enumFrom :: Wrapped a -> [Wrapped a] # enumFromThen :: Wrapped a -> Wrapped a -> [Wrapped a] # enumFromTo :: Wrapped a -> Wrapped a -> [Wrapped a] # enumFromThenTo :: Wrapped a -> Wrapped a -> Wrapped a -> [Wrapped a] # | |
Num a => Num (Wrapped a) Source # | |
Defined in Futhark.Util.IntegralExp | |
Show a => Show (Wrapped a) Source # | |
Integral a => IntegralExp (Wrapped a) Source # | |
Defined in Futhark.Util.IntegralExp | |
Eq a => Eq (Wrapped a) Source # | |
Ord a => Ord (Wrapped a) Source # | |
Defined in Futhark.Util.IntegralExp |