Skip to content

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

Merged
merged 4 commits into from
Apr 7, 2018
Merged

Add Unfoldable1 #22

merged 4 commits into from
Apr 7, 2018

Conversation

garyb
Copy link
Member

@garyb garyb commented Apr 1, 2018

Resolves #19

/cc @matthewleon

import Data.Tuple (Tuple(..))

-- | This class identifies non-empty data structures which can be _unfolded_,
-- | generalizing `unfoldr1` on non-empty lists or arrays.
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

:: forall m f a
. Applicative m
=> Unfoldable1 f
=> Traversable f
Copy link
Contributor

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?

@garyb
Copy link
Member Author

garyb commented Apr 1, 2018

I'm glad one of us is paying attention 😉

| i <= 0 = Tuple v Nothing
| otherwise = Tuple v (Just (i - 1))

-- | Perform an `Applicative` action `n` times (at least once, so values `n < 1`
Copy link
Contributor

@matthewleon matthewleon Apr 2, 2018

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.

Copy link
Member Author

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 😄

matthewleon added a commit to matthewleon/purescript-nonempty that referenced this pull request Apr 6, 2018
@garyb
Copy link
Member Author

garyb commented Apr 6, 2018

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.

@garyb garyb merged commit 91297ed into master Apr 7, 2018
@garyb garyb deleted the unfoldable1 branch April 7, 2018 10:21
matthewleon added a commit to matthewleon/purescript-nonempty that referenced this pull request Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants