Skip to content

Instantly share code, notes, and snippets.

@h-hirai
Last active December 18, 2015 04:59
Show Gist options
  • Save h-hirai/5729295 to your computer and use it in GitHub Desktop.
Save h-hirai/5729295 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
data Hoge = A Int
| B Bool
| C Char
| D
| E String deriving Show
makePrisms ''Hoge
{-
*Main> has _A (A 3)
True
*Main> has _A (B False)
False
*Main> (E "hoge") ^? _A
Nothing
*Main> (E "hoge") ^? _E
Just "hoge"
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment