Last active
July 9, 2020 06:23
-
-
Save tonymorris/6f38d27a197e5b8fc9e9b0d041c1a344 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 LambdaCase #-} | |
import Control.Lens | |
data Blah a = | |
Blah1 a | |
| Blah2 a | |
| BlahS String | |
deriving (Eq, Show) | |
isBlah1orS :: Blah a -> Bool | |
isBlah1orS b = not (isn't _Blah1 b || isn't _BlahS b) | |
_Blah1 :: Prism' (Blah a) a | |
_Blah1 = | |
prism' | |
Blah1 | |
(\case | |
Blah1 a -> Just a | |
_ -> Nothing | |
) | |
_Blah2 :: Prism' (Blah a) a | |
_Blah2 = | |
prism' | |
Blah2 | |
(\case | |
Blah2 a -> Just a | |
_ -> Nothing | |
) | |
_BlahS :: Prism' (Blah a) String | |
_BlahS = | |
prism' | |
BlahS | |
(\case | |
BlahS s -> Just s | |
_ -> Nothing | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment