uberlast-0.0: Generate overloaded lenses from plain data declaration

Copyright(c) Fumiaki Kinoshita 2014
LicenseBSD3
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Control.Lens.Overload

Description

 

Synopsis

Documentation

class Has s a where Source

a has a field named s

Associated Types

type Field s a :: * Source

Methods

theField :: Proxy s -> Lens' a (Field s a) Source

declareHas :: DecsQ -> DecsQ Source

Generate Has instances from data type declaration. declareHas [d|data Stuff = Stuff { position :: V3 Float, velocity :: V3 Float, weight :: Float}|] will create @

data Stuff = Stuff (V3 Float) (V3 Float) Float

instance Has "position" Stuff where

  type Field "position" Stuff = V3 Float

  theField = ...

instance Has "velocity" Stuff where

  type Field "velocity" Stuff = V3 Float

  theField = ...

instance Has "weight" Stuff where

  type Field "weight" Stuff = Float

  theField = ...

makeField :: String -> DecsQ Source

Create an alias of theField so that you don't have to specify a type signature by hand.