peakachu-0.3.0: Experiemental library for composable interactive programs

Data.ADT.Getters

Description

ADT getters generation with Template Haskell

Example:

 {-# LANGUAGE TemplateHaskell #-}
 data Blah a = NoBlah | YesBlah a | ManyBlah a Int
 $(mkADTGetters ''Blah)

Generates

 gNoBlah :: Blah a -> Maybe ()
 gYesBlah :: Blah a -> Maybe a
 gManyBlah :: Blah a -> Maybe (a, Int)

Where

 gYesBlah (YesBlah a) = Just a
 gYesBlah _ = Nothing

etc.

Documentation