Skip to content
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

Round out data/list #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Shamrock-Frost
Copy link
Contributor

The git history should be a lot nicer now.

@lexi-lambda
Copy link
Owner

This looks great. Two questions:

  1. Is there any reason to call /= not=? I think /= is an alright name, though I’m open to arguments against it.

  2. Can you add documentation for the functions added in the last of these three commits?

Thanks.

@Shamrock-Frost
Copy link
Contributor Author

For 1, I was copying what clojure called it (same with nth). I'll change it to /= to keep with haskell. I'll add documentation tonight, sorry for the delay.

@lexi-lambda
Copy link
Owner

Oh, gotcha, I didn’t realize Clojure had a function named not=. It probably doesn’t matter too much, but I think it makes sense to stick with Haskell here.

And no worries—I’d just like to make it a policy to avoid adding functions to the standard library without also adding documentation, but there’s no rush.

@Shamrock-Frost
Copy link
Contributor Author

The documentation has been added.

128)
(take 5 (unfoldr (λ [x] (Just (Tuple x {x + 2}))) 0)))}

@defproc[(concat [_ (Monoid m)] [ms (t:List m)]) m]{
Copy link
Owner

Choose a reason for hiding this comment

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

These uses of Monoid need to be t:Monoid to be properly linked.


@(hackett-examples
(unfoldr (λ [x] (if {x == 1} Nothing
(Just (Tuple (show x) (quotient! x 2)))))
Copy link
Owner

Choose a reason for hiding this comment

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

If you’re going to use quotient! and remainder! in examples, they probably need documentation as well. (My policy so far has basically been to document everything undocumented as I use them in other pieces of documentation.)

@defproc[(fold-map [_ (Monoid m)] [f {a t:-> m}] [xs (List a)]) m]{

Applies @racket[f] to each element of @racket[xs] and concatenates each resulting list. Equivalent
to @racket[=<<] when @racket[m] is @racket[(List b)] for some @racket[b].
Copy link
Owner

Choose a reason for hiding this comment

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

The two uses of List here should be t:List.

(all? (<= 2) {1 :: (error! "never happens") :: Nil})
(all? (<= 1) Nil))}

@defproc[(elem? [_ (t:Eq a)] [x a] [xs (t:List a)]) t:Bool]{
Copy link
Owner

Choose a reason for hiding this comment

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

I don’t think there’s currently a great way to typeset this sort of function, but I don’t think this is a good way. Maybe just use defthing here for now.

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.

None yet

2 participants