Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Copilot.Language.Operators.Projection
Description
Interface to access portions of a larger data structure.
Default operations to access elements from structs and arrays (e.g., a field of a struct, an element of an array) allow obtaining the values of those elements, but not modifying.
This module defines a common interface to manipulate portions of a larger data structure. We define the interface in a generic way, using a type class with two operations: one to set the value of the sub-element, and one to update the value of such element applying a stream function.
Synopsis
- class Projectable d s t | d s -> t where
- data Projection d s t
- (=:) :: Projection d s t -> Stream t -> Stream d
- (=$) :: Projection d s t -> (Stream t -> Stream t) -> Stream d
Documentation
class Projectable d s t | d s -> t where Source #
Common interface to manipulate portions of a larger data structure.
A projectable d s t means that it is possible to manipulate a sub-element s of type t carried in a stream of type d.
Methods
(=:) :: Projection d s t -> Stream t -> Stream d infixl 8 Source #
Modify the value of a sub-element of a type in a stream of elements of that type.
(=$) :: Projection d s t -> (Stream t -> Stream t) -> Stream d infixl 8 Source #
Update the value of a sub-element of a type in a stream of elements of that type, by applying a function on streams.
Instances
(KnownSymbol f, Typed s, Typed t, Struct s) => Projectable s (s -> Field f t) t Source # | Update a stream of structs. |
Defined in Copilot.Language.Operators.Struct Associated Types data Projection s (s -> Field f t) t Source # | |
(KnownNat n, Typed t) => Projectable (Array n t) (Stream Word32) t Source # | Update a stream of arrays. |
Defined in Copilot.Language.Operators.Array |