TheSeamau5 / elm-check

Property Based Testing in Elm
70 stars 20 forks source link

Considering type signature change for `tuple*` #12

Closed avh4 closed 9 years ago

avh4 commented 9 years ago

My first impression of using tuple is that the signature should be

tuple : Investigator a -> Investigator b -> Investigator (a, b)

instead of

tuple : (Investigator a, Investigator b) -> Investigator (a, b)

And likewise for tupleN

I thought I'd just log my opinion here. Feel free to close if you think the current API is correct.

TheSeamau5 commented 9 years ago

Yeah, I consciously made that choice to make the investigators sorta look like type signatures.

The idea is that tests would look like this:

claim_reverse_append = 
  claim
    "Appending two lists then reversing the result is equivalent to reversing each list then appending"
  `that`
    (\(xs, ys) -> reverse (xs ++ ys))
  `is`
    (\(xs, ys) -> reverse xs ++ reverse ys)
  `for`
    tuple (list int, list int)

But later on, I'm planning on making some changes to investigators which will make it possible to define map, map2, andThen, etc... As such, if you really want that function, you'll just be able to call zip

zip = map2 (,)