-
Notifications
You must be signed in to change notification settings - Fork 80
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
testable for seq and contramap (for testable) #412
Conversation
src/alcotest-engine/test.mli
Outdated
@@ -107,6 +110,10 @@ val neg : 'a testable -> 'a testable | |||
(** [neg t] is [t]'s negation: it is [true] when [t] is [false] and it is | |||
[false] when [t] is [true]. *) | |||
|
|||
val contramap : ('b -> 'a) -> 'a testable -> 'b testable |
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.
Do you mind naming this map
-- even if it doesn't follow the theory, that's what more users would expect :p
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.
What do you think about keeping the Fmt
convention by calling it using
? (Because I find that calling it map
makes reading its signature ... complicated).
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.
Hm, btw you are right, map
works well, fixed on 415abb4
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.
using
could work too - no strong opinion between map
and using
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 go for map
:)
Thanks that looks like a great addition! LGTM apart questions on names (the most difficult questions, as usual) |
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.
Seq.uncons
was introduced in OCaml 4.14. We may want to keep supporting OCaml 4.08 for a while still.
This PR adds:
seq
(to produces'a Seq.t testable
) Because theSeq.t
type has become very common in the standard librarycontramap
which allows you to go from an'a testable
to a'b testable
giving a function fromb -> 'a
(because a testable is a contravariant functor). I have often found the function useful for implementing testables quickly when there is a trivial transformation.