generic-lens-0.3.0.0: Generic data-structure operations exposed as lenses.

Copyright(C) 2017 Csongor Kiss
LicenseBSD3
MaintainerCsongor Kiss <kiss.csongor.kiss@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell2010

Data.Generics.Sum.Typed

Contents

Description

Derive constructor-field-type-based prisms generically.

Synopsis

Prisms

class AsType a s where #

Sums that have a constructor with a field of the given type.

Methods

_Typed :: Prism' s a #

A prism that projects a constructor uniquely identifiable by the type of its field. Compatible with the lens package's Prism type.

>>> dog ^? _Typed @Dog
Just (MkDog {name = "Shep", age = 3})
>>> dog ^? _Typed @Cat
Nothing
>>> duck ^? _Typed @Age
Just 2

Instances

(Generic s, ErrorUnlessOne a s (CountPartialType a (Rep s)), GAsType (Rep s) a) => AsType a s # 

Methods

_Typed :: Prism' s a #

Internals

class GAsType f a where #

As AsType but over generic representations as defined by GHC.Generics.

Methods

_GTyped :: Prism' (f x) a #

Instances

GSumAsType l r a (HasPartialTypeP a l) => GAsType ((:+:) l r) a # 

Methods

_GTyped :: (Choice p, Applicative f) => p a (f a) -> p ((l :+: r) x) (f ((l :+: r) x)) #

GAsType f a => GAsType (M1 D meta f) a # 

Methods

_GTyped :: (Choice p, Applicative f) => p a (f a) -> p (M1 D meta f x) (f (M1 D meta f x)) #

GCollectible f ((:) Type a ([] Type)) => GAsType (M1 C meta f) a # 

Methods

_GTyped :: (Choice p, Applicative f) => p a (f a) -> p (M1 C meta f x) (f (M1 C meta f x)) #

GAsType f a => GAsType (M1 S meta f) a # 

Methods

_GTyped :: (Choice p, Applicative f) => p a (f a) -> p (M1 S meta f x) (f (M1 S meta f x)) #