futhark-data-1.0.2.0: An implementation of the Futhark data format.
Safe HaskellNone
LanguageHaskell2010

Futhark.Data

Description

This module defines an efficient value representation of the Futhark data format.

Synopsis

Documentation

data Value Source #

An efficiently represented Futhark value, represented as a shape vector and a value vector, which contains elements in row-major order. The size of the value vector must be equal to the product of the shape vector. This is not enforced by the representation, but consuming functions may give unexpected results if this invariant is broken. Scalars are represented with an empty shape vector.

Use valueText to get a human-readable representation, and put to obtain binary a representation.

The Eq instance is the naive one, meaning that no values containing NaNs will be considered equal. Use the functions from Futhark.Data.Compare if this is not what you want.

Instances

Instances details
Eq Value Source # 
Instance details

Defined in Futhark.Data

Methods

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

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

Show Value Source # 
Instance details

Defined in Futhark.Data

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

Binary Value Source # 
Instance details

Defined in Futhark.Data

Methods

put :: Value -> Put #

get :: Get Value #

putList :: [Value] -> Put #

PutValue [Value] Source # 
Instance details

Defined in Futhark.Data

Methods

putValue :: [Value] -> Maybe Value Source #

type Vector = Vector Source #

The value vector type.

valueText :: Value -> Text Source #

Construct a textual representation of the value as a strict text.

Types of values

data PrimType Source #

The scalar types supported by the value format.

Constructors

I8 
I16 
I32 
I64 
U8 
U16 
U32 
U64 
F16 
F32 
F64 
Bool 

Instances

Instances details
Bounded PrimType Source # 
Instance details

Defined in Futhark.Data

Enum PrimType Source # 
Instance details

Defined in Futhark.Data

Eq PrimType Source # 
Instance details

Defined in Futhark.Data

Ord PrimType Source # 
Instance details

Defined in Futhark.Data

Show PrimType Source # 
Instance details

Defined in Futhark.Data

primTypeText :: PrimType -> Text Source #

Textual primitive type as a strict text.

primTypeBytes :: PrimType -> Int Source #

The number of bytes taken up by a single element of this type.

data ValueType Source #

The type of a simple Futhark value, comprising a shape and an element type.

Constructors

ValueType [Int] PrimType 

Instances

Instances details
Eq ValueType Source # 
Instance details

Defined in Futhark.Data

Ord ValueType Source # 
Instance details

Defined in Futhark.Data

Show ValueType Source # 
Instance details

Defined in Futhark.Data

valueTypeTextNoDims :: ValueType -> Text Source #

Prettyprint a value type with empty dimensions as a strict text. This is needed for Futhark server programs, whose types are un-sized.

valueType :: Value -> ValueType Source #

Get the type of a value.

valueElemType :: Value -> PrimType Source #

Get the element type of a value.

valueShape :: Value -> [Int] Source #

The shape of a value. Empty list in case of a scalar.

valueTypeText :: ValueType -> Text Source #

Prettyprint a value type as a strict text.

Converting values

class GetValue t where Source #

A class for Haskell values that can be retrieved from Value. This is a convenience facility - don't expect it to be fast.

Methods

getValue :: Value -> Maybe t Source #

Instances

Instances details
GetValue Bool Source # 
Instance details

Defined in Futhark.Data

GetValue Int8 Source # 
Instance details

Defined in Futhark.Data

GetValue Int16 Source # 
Instance details

Defined in Futhark.Data

GetValue Int32 Source # 
Instance details

Defined in Futhark.Data

GetValue Int64 Source # 
Instance details

Defined in Futhark.Data

GetValue Word8 Source # 
Instance details

Defined in Futhark.Data

GetValue Word16 Source # 
Instance details

Defined in Futhark.Data

GetValue Word32 Source # 
Instance details

Defined in Futhark.Data

GetValue Word64 Source # 
Instance details

Defined in Futhark.Data

GetValue t => GetValue [t] Source # 
Instance details

Defined in Futhark.Data

Methods

getValue :: Value -> Maybe [t] Source #

class PutValue t where Source #

A class for Haskell values that can be converted to Value. This is a convenience facility - don't expect it to be fast.

Methods

putValue :: t -> Maybe Value Source #

This may fail for cases such as irregular arrays.

Instances

Instances details
PutValue Int8 Source # 
Instance details

Defined in Futhark.Data

PutValue Int16 Source # 
Instance details

Defined in Futhark.Data

PutValue Int32 Source # 
Instance details

Defined in Futhark.Data

PutValue Int64 Source # 
Instance details

Defined in Futhark.Data

PutValue Word8 Source # 
Instance details

Defined in Futhark.Data

PutValue Word16 Source # 
Instance details

Defined in Futhark.Data

PutValue Word32 Source # 
Instance details

Defined in Futhark.Data

PutValue Word64 Source # 
Instance details

Defined in Futhark.Data

PutValue ByteString Source # 
Instance details

Defined in Futhark.Data

PutValue Text Source # 
Instance details

Defined in Futhark.Data

PutValue [Value] Source # 
Instance details

Defined in Futhark.Data

Methods

putValue :: [Value] -> Maybe Value Source #

valueElems :: Value -> [Value] Source #

Produce a list of the immediate elements of the value. That is, a 2D array will produce a list of 1D values. A zero-dimensional value will produce an empty list. While lists are of course inefficient, the actual values are just slices of the original value, which makes them fairly space-efficient (but beware space leaks).