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 # divUp :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # | |
IntegralExp e => IntegralExp (Count u e) Source # | |
Defined in Futhark.IR.Kernels.Sizes |
This wrapper allows you to use a type that is an instance of the true class whenever the simile class is required.
Wrapped | |
|