Created
October 22, 2019 09:33
-
-
Save tonymorris/c22e48e6e12f06f794f94ba8a3272681 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
nonEmptyIso :: | |
Iso [a] [b] (Maybe (NonEmpty a)) (Maybe (NonEmpty b)) | |
nonEmptyIso = | |
iso | |
( | |
\case | |
[] -> | |
Nothing | |
h:t -> | |
Just (h:|t) | |
) | |
( | |
\case | |
Nothing -> | |
[] | |
Just (h:|t) -> | |
h:t | |
) | |
blah :: | |
[Maybe a] | |
-> Maybe (NonEmpty a) | |
blah = | |
view nonEmptyIso . catMaybes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment