Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Language.Futhark.Interpreter.Values
Contents
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
- data Shape d
- type ValueShape = Shape Int64
- typeShape :: TypeBase d u -> Shape d
- structTypeShape :: StructType -> Shape (Maybe Int64)
- data Value m
- = ValuePrim !PrimValue
- | ValueArray ValueShape !(Array Int (Value m))
- | ValueRecord (Map Name (Value m))
- | ValueFun (Value m -> m (Value m))
- | ValueSum ValueShape Name [Value m]
- | ValueAcc ValueShape (Value m -> Value m -> m (Value m)) !(Array Int (Value m))
- | ValueAD Int ADVariable
- valueShape :: Value m -> ValueShape
- prettyValue :: Value m -> Doc a
- valueText :: Value m -> Text
- valueAccum :: (a -> Value m -> (a, Value m)) -> a -> Value m -> (a, Value m)
- valueAccumLM :: Monad f => (a -> Value m -> f (a, Value m)) -> a -> Value m -> f (a, Value m)
- fromTuple :: Value m -> Maybe [Value m]
- arrayLength :: Integral int => Array Int (Value m) -> int
- isEmptyArray :: Value m -> Bool
- prettyEmptyArray :: TypeBase () () -> Value m -> Text
- toArray :: ValueShape -> [Value m] -> Value m
- toArray' :: ValueShape -> [Value m] -> Value m
- toTuple :: [Value m] -> Value m
- fromDataValue :: Value -> Value m
Shapes
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
Foldable Shape Source # | |
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 # elem :: Eq a => a -> Shape a -> Bool # maximum :: Ord a => Shape a -> a # minimum :: Ord a => Shape a -> a # | |
Traversable Shape Source # | |
Functor Shape Source # | |
Show d => Show (Shape d) Source # | |
Eq d => Eq (Shape d) Source # | |
Pretty d => Pretty (Shape d) Source # | |
Defined in Language.Futhark.Interpreter.Values |
type ValueShape = Shape Int64 Source #
The shape of an array.
structTypeShape :: StructType -> Shape (Maybe Int64) Source #
Values
A fully evaluated Futhark value.
Constructors
ValuePrim !PrimValue | |
ValueArray ValueShape !(Array Int (Value m)) | |
ValueRecord (Map Name (Value m)) | |
ValueFun (Value m -> m (Value m)) | |
ValueSum ValueShape Name [Value m] | |
ValueAcc ValueShape (Value m -> Value m -> m (Value m)) !(Array Int (Value m)) | |
ValueAD Int ADVariable |
valueShape :: Value m -> ValueShape Source #
prettyValue :: Value m -> Doc a Source #
Prettyprint value.
valueAccumLM :: Monad f => (a -> Value m -> f (a, Value m)) -> a -> Value m -> f (a, Value m) 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.
Conversion
fromDataValue :: Value -> Value m Source #
Convert a Futhark value in the externally observable data format to an interpreter value.