mu-optics-0.2.0.0: Optics for @mu-schema@ terms

Safe HaskellNone
LanguageHaskell2010

Mu.Schema.Optics

Contents

Description

This module provides instances of LabelOptic to be used in conjunction with the optics package. In particular, there are two kind of optics to access different parts of a Term:

  • With #field you obtain the lens (that is, a getter and a setter) for the corresponding field in a record.
  • With #choice you obtain the prism for the desired choice in an enumeration. You can use then review to construct a term with the value.

In addition, we provide a utility function record to build a record out of the inner values. We intend the interface to be very simple, so this function is overloaded to take tuples of different size, with as many components as values in the schema type.

Synopsis

Build a term

record :: BuildRecord w sch args r => r -> Term w sch (DRecord name args) Source #

record1 :: BuildRecord1 w sch arg r => r -> Term w sch (DRecord name '[arg]) Source #

enum :: forall (choiceName :: Symbol) choices w sch name. EnumLabel choices choiceName => Term w sch (DEnum name choices) Source #

_U0 :: forall w (sch :: Schema') x xs r. TypeLabel w sch x r => Prism' (NS (FieldValue w sch) (x ': xs)) r Source #

_Next :: forall w (sch :: Schema') x xs. Prism' (NS (FieldValue w sch) (x ': xs)) (NS (FieldValue w sch) xs) Source #

_U1 :: forall w (sch :: Schema') a b xs r. TypeLabel w sch b r => Prism' (NS (FieldValue w sch) (a ': (b ': xs))) r Source #

_U2 :: forall w (sch :: Schema') a b c xs r. TypeLabel w sch c r => Prism' (NS (FieldValue w sch) (a ': (b ': (c ': xs)))) r Source #

_U3 :: forall w (sch :: Schema') a b c d xs r. TypeLabel w sch d r => Prism' (NS (FieldValue w sch) (a ': (b ': (c ': (d ': xs))))) r Source #

Re-exported for convenience.

Orphan instances

(EnumLabel choices choiceName, r ~ ()) => LabelOptic choiceName A_Prism (Term w sch (DEnum name choices :: TypeDefB Type typeName Symbol)) (Term w sch (DEnum name choices :: TypeDefB Type typeName Symbol)) r r Source # 
Instance details

Methods

labelOptic :: Optic A_Prism NoIx (Term w sch (DEnum name choices)) (Term w sch (DEnum name choices)) r r #

(FieldLabel w sch args fieldName r, t ~ w r) => LabelOptic fieldName A_Lens (Term w sch (DRecord name args)) (Term w sch (DRecord name args)) t t Source # 
Instance details

Methods

labelOptic :: Optic A_Lens NoIx (Term w sch (DRecord name args)) (Term w sch (DRecord name args)) t t #

FieldLabel Identity sch args fieldName r => LabelOptic fieldName A_Lens (Term Identity sch (DRecord name args)) (Term Identity sch (DRecord name args)) r r Source # 
Instance details

Methods

labelOptic :: Optic A_Lens NoIx (Term Identity sch (DRecord name args)) (Term Identity sch (DRecord name args)) r r #