-
Notifications
You must be signed in to change notification settings - Fork 23
Add Unfoldable1
#22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Unfoldable1
#22
Conversation
src/Data/Unfoldable1.purs
Outdated
import Data.Tuple (Tuple(..)) | ||
|
||
-- | This class identifies non-empty data structures which can be _unfolded_, | ||
-- | generalizing `unfoldr1` on non-empty lists or arrays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfoldr1
is not provided elsewhere, so maybe nix that part of the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good point, unfoldr
is not provided elsewhere either so I guess that applies to both modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must have been copy-paste from some Haskell?
src/Data/Unfoldable1.purs
Outdated
:: forall m f a | ||
. Applicative m | ||
=> Unfoldable1 f | ||
=> Traversable f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Traversable1
would let you generalize to Apply
, no?
I'm glad one of us is paying attention 😉 |
src/Data/Unfoldable1.purs
Outdated
| i <= 0 = Tuple v Nothing | ||
| otherwise = Tuple v (Just (i - 1)) | ||
|
||
-- | Perform an `Applicative` action `n` times (at least once, so values `n < 1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you want this to still say Applicative
, though "Perform an Apply
action" doesn't read well either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with saying exactly that in the end, it does read a little strangely because of the syntax at the English level, but it's not inaccurate 😄
will amend upon merging of purescript/purescript-unfoldable#22
Oh right! I knew there was something I had left pending. Will update the comment and merge this tomorrow, I'm off to bed now. |
will amend upon merging of purescript/purescript-unfoldable#22
Resolves #19
/cc @matthewleon