liqwid-plutarch-extra-3.21.1: A collection of Plutarch extras from Liqwid Labs
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plutarch.Extra.Optics

Synopsis

Type families for constraints

type family HasLabelled (opt :: Type) (k :: Type) (s :: Type) (labels :: [(Symbol, Type)]) :: Constraint where ... Source #

Describes that a type s has a collection of labelled optics, all of type k, which is at least as capable as opt (though could be more so). labels describes which optics s must have, as name-result pairs.

Note

This type family unfortunately has two caveats to its use:

  • Redundant constraints resulting from its use won't be picked up by GHC warnings.
  • If labels is empty, you will get an overlapping instances error.

Keep these in mind when using.

Since: 3.15.2

Equations

HasLabelled opt k s '[] = k `Is` opt 
HasLabelled opt k s ('(sym, t) ': labels) = (LabelOptic sym k s s t t, HasLabelled opt k s labels) 

type HasLabelledGetters (k :: Type) (s :: Type) (labels :: [(Symbol, Type)]) = HasLabelled A_Getter k s labels Source #

Deprecated: Use HasLabelled A_Getter instead.

Short for HasLabelled A_Getter.

Note from Koz: To avoid breaking everything, I've made this a type synonym for now, while folks act on the deprecation warning. Not ideal, but far less damaging.

Since: 3.10.3

Helper functions

inspect :: forall (m :: Type -> Type) (r :: Type) (k :: Type) (is :: [Type]) (a :: Type). (MonadReader r m, Is k A_Getter) => Optic' k is r a -> m a Source #

view the MonadReader environment using the provided optic.

Since: 3.14.3

inspects :: forall (m :: Type -> Type) (r :: Type) (k :: Type) (is :: [Type]) (a :: Type) (b :: Type). (MonadReader r m, Is k A_Getter) => Optic' k is r a -> (a -> b) -> m b Source #

As inspect, but using views instead of view.

Since: 3.14.3

guarantee :: forall (k :: Type) (is :: [Type]) (s :: Type) (a :: Type). Is k An_AffineFold => a -> Optic' k is s a -> s -> a Source #

As preview, but also gives a default in case the optic 'misses'.

Since: 3.15.2

guarantees :: forall (k :: Type) (is :: [Type]) (s :: Type) (a :: Type) (b :: Type). Is k An_AffineFold => b -> Optic' k is s a -> (a -> b) -> s -> b Source #

As previews, but also gives a default in case the optic 'misses'.

Since: 3.15.2