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.HasConstructor

Description

Derive prisms generically

data FooBar
  = Foo Int
  | Bar Int String
  | Baz (Int, String)
  | Qux
  deriving (Show, Generic)

>>> Bar 5 "coconut" ^? as @"Bar"
Just (5, "coconut")
>>> Qux ^? as @"Qux"
Just ()
>>> as @"Bar" # (5, "asd") :: FooBar
Bar 5 "asd"

Documentation

class HasConstructor con a s | s con -> a where #

Minimal complete definition

as

Methods

as :: Prism' s a #

Instances

(Generic s, ErrorUnless (ContainsC con (Rep s)) con s, GHasConstructor con (Rep s) a) => HasConstructor con a s # 

Methods

as :: Prism' s a #