futhark-0.25.15: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageGHC2021

Language.Futhark.Interpreter.Values

Description

The value representation used in the interpreter.

Kept simple and free of unnecessary operational details (in particular, no references to the interpreter monad).

Synopsis

Shapes

data Shape d Source #

A shape is a tree to accomodate the case of records. It is parameterised over the representation of dimensions.

Constructors

ShapeDim d (Shape d) 
ShapeLeaf 
ShapeRecord (Map Name (Shape d)) 
ShapeSum (Map Name [Shape d]) 

Instances

Instances details
Foldable Shape Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

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

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

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

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

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

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

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

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

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

toList :: Shape a -> [a] #

null :: Shape a -> Bool #

length :: Shape a -> Int #

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

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

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

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

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

Traversable Shape Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

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

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

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

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

Functor Shape Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

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

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

Show d => Show (Shape d) Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

showsPrec :: Int -> Shape d -> ShowS #

show :: Shape d -> String #

showList :: [Shape d] -> ShowS #

Eq d => Eq (Shape d) Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

(==) :: Shape d -> Shape d -> Bool #

(/=) :: Shape d -> Shape d -> Bool #

Pretty d => Pretty (Shape d) Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

pretty :: Shape d -> Doc ann #

prettyList :: [Shape d] -> Doc ann #

type ValueShape = Shape Int64 Source #

The shape of an array.

Values

data Value m Source #

A fully evaluated Futhark value.

Instances

Instances details
Show (Value m) Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

showsPrec :: Int -> Value m -> ShowS #

show :: Value m -> String #

showList :: [Value m] -> ShowS #

Eq (Value m) Source # 
Instance details

Defined in Language.Futhark.Interpreter.Values

Methods

(==) :: Value m -> Value m -> Bool #

(/=) :: Value m -> Value m -> Bool #

prettyValue :: Value m -> Doc a Source #

Prettyprint value.

valueText :: Value m -> Text Source #

The value in the textual format.

arrayLength :: Integral int => Array Int (Value m) -> int Source #

isEmptyArray :: Value m -> Bool Source #

Does the value correspond to an empty array?

prettyEmptyArray :: TypeBase () () -> Value m -> Text Source #

String representation of an empty array with the provided element type. This is pretty ad-hoc - don't expect good results unless the element type is a primitive.

toTuple :: [Value m] -> Value m Source #

Conversion

fromDataValue :: Value -> Value m Source #

Convert a Futhark value in the externally observable data format to an interpreter value.