Last active
December 18, 2015 04:59
-
-
Save h-hirai/5729295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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