testable for seq and contramap (for testable)#412
Conversation
| (** [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.
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.
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.
Hm, btw you are right, map works well, fixed on 415abb4
There was a problem hiding this comment.
using could work too - no strong opinion between map and using
|
Thanks that looks like a great addition! LGTM apart questions on names (the most difficult questions, as usual) |
MisterDA
left a comment
There was a problem hiding this comment.
Seq.uncons was introduced in OCaml 4.14. We may want to keep supporting OCaml 4.08 for a while still.
CHANGES: - Add `seq`, a testable for `Seq.t` and `contramap` (mirage/alcotest#412 @xvw) - Expose the `V1.Skip` exception (mirage/alcotest#415, mirage/alcotest#416, @Khady) - BREAKING FIX: `match_raises` now expects the user-defined function to return true for expected exceptions. Previously false was interpreted as an expected exception. (mirage/alcotest#418, mirage/alcotest#419, @psafont)
This PR adds:
seq(to produces'a Seq.t testable) Because theSeq.ttype has become very common in the standard librarycontramapwhich allows you to go from an'a testableto a'b testablegiving 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.