Skip to content

Add more documentation examples #35

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

milesfrain
Copy link

@milesfrain milesfrain commented May 2, 2021

In Progress

Description of the change

Fixes #31

Adding some more description and examples


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

Comment on lines +28 to +32
-- | unfoldr1 g 3 == NEA.cons' 3 [2, 1, 0]
-- | unfoldr1 g 3 == NEL.cons' 3 (2 : 1 : 0 : Nil)
-- | -- Also produces structures of types which can be empty
-- | unfoldr1 g 3 == [3, 2, 1, 0]
-- | unfoldr1 g 3 == 3 : 2 : 1 : 0 : Nil
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this REPL-style sequence is clearer:

> unfoldr1 g 3 :: NonEmptyArray Int
(NonEmptyArray [3,2,1,0])
> unfoldr1 g 3 :: NonEmptyList _
(NonEmptyList (NonEmpty 3 (2 : 1 : 0 : Nil)))
> unfoldr1 g 3 :: Array _
[3,2,1,0]
> unfoldr1 g 3 :: List _
(3 : 2 : 1 : 0 : Nil)

Also, there's some inconsistency with show for NonEmptyArray vs NonEmptyList. The Array version is a lot more concise.

Comment on lines +95 to +98
-- | > replicate1A 2 (randomInt 1 10) :: Effect (NonEmptyList Int)
-- | (NonEmptyList (NonEmpty 8 (2 : Nil)))
-- | > replicate1A 0 (randomInt 1 10) :: Effect (NEL.NonEmptyList Int)
-- | (NonEmptyList (NonEmpty 4 Nil))
-- | > replicate1A 0 (randomInt 1 10) :: _ (NonEmptyArray _)
-- | (NonEmptyArray [3])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these work too? Missing Traversable1:

replicate1A 0 (randomInt 1 10) :: _ (List _)
replicate1A 2 (randomInt 1 10) :: _ (Array _)

Comment on lines 123 to 125
-- | range 0 0 == (NEL.singleton 0 :: NEL.NonEmptyList Int)
-- | range 1 2 == (NEL.cons 1 (NEL.singleton 2) :: NEL.NonEmptyList Int)
-- | range 2 0 == (NEL.cons 2 (NEL.cons 1 (NEL.singleton 0)) :: NEL.NonEmptyList Int)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing the Non-empty examples is kinda clumsy without purescript/purescript-lists#190

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.

Improve documentation
1 participant