Skip to content

Add Unfoldable1#22

Merged
garyb merged 4 commits into
masterfrom
unfoldable1
Apr 7, 2018
Merged

Add Unfoldable1#22
garyb merged 4 commits into
masterfrom
unfoldable1

Conversation

@garyb
Copy link
Copy Markdown
Member

@garyb garyb commented Apr 1, 2018

Resolves #19

/cc @matthewleon

Comment thread 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.
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

Comment thread src/Data/Unfoldable1.purs Outdated
:: forall m f a
. Applicative m
=> Unfoldable1 f
=> Traversable f
Copy link
Copy Markdown
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
Copy Markdown
Member Author

garyb commented Apr 1, 2018

I'm glad one of us is paying attention 😉

Comment thread 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`
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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