Skip to content

Instantly share code, notes, and snippets.

@tonymorris
Created April 8, 2022 04:56
Show Gist options
  • Save tonymorris/6fcd16b4e3dc7b9abc071056a0417d4b to your computer and use it in GitHub Desktop.
Save tonymorris/6fcd16b4e3dc7b9abc071056a0417d4b to your computer and use it in GitHub Desktop.
{-# 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