Skip to content

Instantly share code, notes, and snippets.

@LightAndLight
Created August 13, 2017 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LightAndLight/e63e23f31d01a368cb1563bfcaf04a16 to your computer and use it in GitHub Desktop.
Save LightAndLight/e63e23f31d01a368cb1563bfcaf04a16 to your computer and use it in GitHub Desktop.
Prisms?
_1st :: Prism' a a' -> Prism' (a, b, c) (a', b, c)
_1st p = prism' (\(a', b, c) -> (p # a', b, c)) (\(a, b, c) -> (,,) <$> a ^? p <*> pure b <*> pure c)
_2nd :: Prism' b b' -> Prism' (a, b, c) (a, b', c)
_2nd p = prism' (\(a, b', c) -> (a, p # b', c)) (\(a, b, c) -> (,,) a <$> b ^? p <*> pure c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment