Safe Haskell | None |
---|---|
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 :: Type -> Type)
- = 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 Depth ADVariable
- valueShape :: forall (m :: Type -> Type). Value m -> ValueShape
- arrayValueShape :: forall (m :: Type -> Type). Value m -> ValueShape
- prettyValue :: forall (m :: Type -> Type) a. Value m -> Doc a
- valueText :: forall (m :: Type -> Type). Value m -> Text
- valueAccum :: forall a (m :: Type -> Type). (a -> Value m -> (a, Value m)) -> a -> Value m -> (a, Value m)
- valueAccumLM :: forall f a (m :: Type -> Type). Monad f => (a -> Value m -> f (a, Value m)) -> a -> Value m -> f (a, Value m)
- fromTuple :: forall (m :: Type -> Type). Value m -> Maybe [Value m]
- arrayLength :: forall int (m :: Type -> Type). Integral int => Array Int (Value m) -> int
- isEmptyArray :: forall (m :: Type -> Type). Value m -> Bool
- prettyEmptyArray :: forall (m :: Type -> Type). TypeBase () () -> Value m -> Text
- toArray :: forall (m :: Type -> Type). ValueShape -> [Value m] -> Value m
- toArray' :: forall (m :: Type -> Type). ValueShape -> [Value m] -> Value m
- toTuple :: forall (m :: Type -> Type). [Value m] -> Value m
- fromDataValue :: forall (m :: Type -> Type). 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
data Value (m :: Type -> Type) Source #
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 Depth ADVariable |
valueShape :: forall (m :: Type -> Type). Value m -> ValueShape Source #
arrayValueShape :: forall (m :: Type -> Type). Value m -> ValueShape Source #
Retrieve the part of the value shape that corresponds to outer array dimensions. This is used for reporting shapes in those cases where the full shape is not important, namely in indexing errors.
valueAccum :: forall a (m :: Type -> Type). (a -> Value m -> (a, Value m)) -> a -> Value m -> (a, Value m) Source #
valueAccumLM :: forall f a (m :: Type -> Type). Monad f => (a -> Value m -> f (a, Value m)) -> a -> Value m -> f (a, Value m) Source #
isEmptyArray :: forall (m :: Type -> Type). Value m -> Bool Source #
Does the value correspond to an empty array?
prettyEmptyArray :: forall (m :: Type -> Type). 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.