indigo-0.6.0: Convenient imperative eDSL over Lorentz.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Indigo.Common.Field

Contents

Description

This module contains a datatype representing a lens to a field, helpers to compose new lens, and type class like StoreHasField returning a lens.

Synopsis

Documentation

type AccessFieldC a name = RElem name (ConstructorFieldNames a) (RIndex name (ConstructorFieldNames a)) Source #

Constraint to access/assign field stored in Rec

fetchField :: forall a name f proxy. AccessFieldC a name => proxy name -> Rec f (ConstructorFieldNames a) -> f name Source #

Get a field from list of fields

assignField :: forall a name f proxy. AccessFieldC a name => proxy name -> f name -> Rec f (ConstructorFieldNames a) -> Rec f (ConstructorFieldNames a) Source #

Assign a field to a value

Lens

data FieldLens dt fname ftype where Source #

Lens to a field. obj.f1.f2.f3 is represented as list names of [f1, f2, f3].

dt is a type of source object (type of obj in example above) fname is a name of target field ("f3" in example above) ftype is a type of target field

However, a lens contains not only name of field but for each field it contains operations to get and set target field.

Constructors

TargetField :: (InstrGetFieldC dt fname, InstrSetFieldC dt fname, GetFieldType dt fname ~ targetFType, AccessFieldC dt fname) => Label fname -> StoreFieldOps dt targetFName targetFType -> FieldLens dt targetFName targetFType 
DeeperField :: (AccessFieldC dt fname, InstrSetFieldC dt fname, HasField (GetFieldType dt fname) targetFName targetFType) => Label fname -> StoreFieldOps dt targetFName targetFType -> FieldLens dt targetFName targetFType 

flSFO :: FieldLens dt fname ftype -> StoreFieldOps dt fname ftype Source #

Access to StoreFieldOps

HasLens

class (KnownValue ftype, KnownValue dt) => HasField dt fname ftype | dt fname -> ftype where Source #

Class like StoreHasField type class but holding a lens to a field.

Methods

fieldLens :: FieldLens dt fname ftype Source #

Instances

Instances details
(InstrSetFieldC dt fname, InstrGetFieldC dt fname, GetFieldType dt fname ~ ftype, AccessFieldC dt fname, KnownSymbol fname, KnownValue ftype, KnownValue dt) => HasField dt (fname :: Symbol) ftype Source #

Default instance for datatype and its direct field name. It will be useful unless you want to refer to a field using a custom name.

Instance details

Defined in Indigo.Common.Field

Methods

fieldLens :: FieldLens dt fname ftype Source #

fieldLensDeeper :: forall dt targetName targetType fname. (AccessFieldC dt fname, HasFieldOfType dt fname (GetFieldType dt fname), HasDupableGetters (GetFieldType dt fname), HasField (GetFieldType dt fname) targetName targetType) => Label fname -> FieldLens dt targetName targetType Source #

Build a lens to deeper field of an object.

fieldLensADT :: forall dt targetFName targetFType fname. (InstrGetFieldC dt fname, InstrSetFieldC dt fname, GetFieldType dt fname ~ targetFType, AccessFieldC dt fname) => Label fname -> FieldLens dt targetFName targetFType Source #

Build a lens to a direct field of an object.