Skip to content

Instantly share code, notes, and snippets.

@tonymorris
Created April 8, 2022 04:56
{-# LANGUAGE LambdaCase #-}
import Control.Lens
data Blah =
Blah1 Int
| Blah2 String
| Blah3 [()]
deriving (Eq, Show)
_Blah1or2 ::
Prism' Blah (Either Int String)
_Blah1or2 =
prism'
(either Blah1 Blah2)
(\case
Blah1 n -> Just (Left n)
Blah2 s -> Just (Right s)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment