Skip to content

Instantly share code, notes, and snippets.

@dminuoso
Created January 9, 2020 22:37
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 dminuoso/d55e18de07bec1843d761cdf71b193e9 to your computer and use it in GitHub Desktop.
Save dminuoso/d55e18de07bec1843d761cdf71b193e9 to your computer and use it in GitHub Desktop.
manyN :: Int -> f a -> f [a]
manyN n v = many_v n
where
many_v 0 = pure []
many_v n = some_v (n - 1) <|> pure []
some_v 0 = pure []
some_v n = liftA2 (:) v (many_v (n - 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment