| 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 o -> Shape d
- 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
- | ValueLazyFFI ValueShape ValueRef [Int64]
- 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 () NoMode -> 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
- asByteString :: forall (m :: Type -> Type). Value m -> Maybe ByteString
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
| Functor Shape Source # | |
| 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 # | |
| 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.
Values
data Value (m :: Type -> Type) Source #
A Futhark value as produced and used by the interpreter. Some of these represent semantically meaningful Futhark values, while others represent internal operational things that should never be returned by an interpreter entry point, but can be observed in its intermediate stage (e.g. when using breakpoints to access the environment).
Constructors
| ValuePrim !PrimValue | A primitive value. |
| ValueArray ValueShape !(Array Int (Value m)) | An array, with explicit shape. The shape is the full shape of the value, including element shape. |
| ValueRecord (Map Name (Value m)) | A record, which also subsumes tuples. |
| ValueFun (Value m -> m (Value m)) | A function value. |
| ValueSum ValueShape Name [Value m] | A sum value. |
| ValueAcc ValueShape (Value m -> Value m -> m (Value m)) !(Array Int (Value m)) | Internal value: an accumulator. Represented by the shape, the update function, and the array. |
| ValueAD Depth ADVariable | Internal value: A primitive value with added information used in automatic differentiation |
| ValueLazyFFI ValueShape ValueRef [Int64] | A lazy reference to a value on a Futhark Server. These can be returned by the interpreter, although the only sane way to use them for anything is to retrieve them. We store the full shape locally, along with the indexes applied so far. |
valueShape :: forall (m :: Type -> Type). Value m -> ValueShape Source #
The shape of a value.
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 () NoMode -> 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 :: forall (m :: Type -> Type). Value -> Value m Source #
Convert a Futhark value in the externally observable data format to an interpreter value.
asByteString :: forall (m :: Type -> Type). Value m -> Maybe ByteString Source #
If the value represents an array of type []u8, then return those bytes.