hedgehogqa / hedgehogqa/fsharp-hedgehog

Gen.map{n} vs Gen.zip[n] confusion

Open
#301 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
F#
Stars
284
Forks
31
PR merge metrics
No merged PRs in 30d

Description

I am confused by our `Gen.map{n}` and `Gen.zip[n]` functions.
https://github.com/hedgehogqa/fsharp-hedgehog/blob/00e45b73453fa3dab4bc4025f0fea5e71eab9659/src/Hedgehog/Gen.fs#L59-L93

Scott Wlaschin [says](https://fsharpforfunandprofit.com/posts/elevated-world/#zip) that `zip` and `map2` are different names for the same function. However, we have defined `zip` as a special case of `map2` (by passing in a constant for one of the arguments).

Scott also says that `map2` should an alternative implementation of `apply`. By alternative, he doesn't mean two implementations with the same output but different runtime behavior (like faster or less memory usage). He means different outputs, like how `List.apply` (which maps a list of length `n` and a list of length `m` to a list of length `n * m`) and `List.zip` (which maps a list of length `n` and a list of length `m` to either a list of length `min(n, m)` or throws an exception if `n <> m`). However, I think our implementation of `map2` has the same output as the corresponding output from `apply`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.