Created
February 13, 2022 02:54
-
-
Save chandru89new/c939146fd88d6bcd5282072c5f6133f6 to your computer and use it in GitHub Desktop.
sequence list maybe a
This file contains hidden or 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
| seqMaybe : List (Maybe a) -> Maybe (List a) | |
| seqMaybe list = | |
| let | |
| go : List (Maybe a) -> Maybe (Array a) -> Maybe (Array a) | |
| go l acc = | |
| case l of | |
| [] -> | |
| acc | |
| head :: tail -> | |
| case head of | |
| Nothing -> | |
| Nothing | |
| Just x -> | |
| go tail (Maybe.map (\a -> Array.push x a) acc) | |
| in | |
| go list (Just Array.empty) |> Maybe.map Array.toList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment