Skip to content

Instantly share code, notes, and snippets.

@h-hirai
Last active December 18, 2015 04:59

Revisions

  1. h-hirai revised this gist Jun 7, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.hs
    Original file line number Diff line number Diff line change
    @@ -15,4 +15,8 @@ makePrisms ''Hoge
    True
    *Main> has _A (B False)
    False
    *Main> (E "hoge") ^? _A
    Nothing
    *Main> (E "hoge") ^? _E
    Just "hoge"
    -}
  2. h-hirai created this gist Jun 7, 2013.
    18 changes: 18 additions & 0 deletions gistfile1.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    {-# 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
    -}