futhark-0.9.1: An optimising compiler for a functional, array-oriented language.

Safe HaskellSafe
LanguageHaskell2010

Futhark.Util.IntegralExp

Description

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.

Synopsis

Documentation

class Num e => IntegralExp e where Source #

Methods

quot :: e -> e -> e Source #

rem :: e -> e -> e Source #

div :: e -> e -> e Source #

mod :: e -> e -> e Source #

sgn :: e -> Maybe Int Source #

fromInt8 :: Int8 -> e Source #

fromInt16 :: Int16 -> e Source #

fromInt32 :: Int32 -> e Source #

fromInt64 :: Int64 -> e Source #

newtype Wrapped a Source #

This wrapper allows you to use a type that is an instance of the true class whenever the simile class is required.

Constructors

Wrapped 

Fields

Instances
Eq a => Eq (Wrapped a) Source # 
Instance details

Defined in Futhark.Util.IntegralExp

Methods

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

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

Num a => Num (Wrapped a) Source # 
Instance details

Defined in Futhark.Util.IntegralExp

Methods

(+) :: Wrapped a -> Wrapped a -> Wrapped a #

(-) :: Wrapped a -> Wrapped a -> Wrapped a #

(*) :: Wrapped a -> Wrapped a -> Wrapped a #

negate :: Wrapped a -> Wrapped a #

abs :: Wrapped a -> Wrapped a #

signum :: Wrapped a -> Wrapped a #

fromInteger :: Integer -> Wrapped a #

Ord a => Ord (Wrapped a) Source # 
Instance details

Defined in Futhark.Util.IntegralExp

Methods

compare :: Wrapped a -> Wrapped a -> Ordering #

(<) :: Wrapped a -> Wrapped a -> Bool #

(<=) :: Wrapped a -> Wrapped a -> Bool #

(>) :: Wrapped a -> Wrapped a -> Bool #

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

max :: Wrapped a -> Wrapped a -> Wrapped a #

min :: Wrapped a -> Wrapped a -> Wrapped a #

Show a => Show (Wrapped a) Source # 
Instance details

Defined in Futhark.Util.IntegralExp

Methods

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

show :: Wrapped a -> String #

showList :: [Wrapped a] -> ShowS #

Integral a => IntegralExp (Wrapped a) Source # 
Instance details

Defined in Futhark.Util.IntegralExp

quotRoundingUp :: IntegralExp num => num -> num -> num Source #

Like IntegralExp, but rounds up.