fantasyland / fantasy-land

Specification for interoperability of common algebraic structures in JavaScript
MIT License
10.08k stars 373 forks source link

Wrong argument in Traversable #318

Closed Ne4to777 closed 4 years ago

Ne4to777 commented 4 years ago

Definition: fantasy-land/traverse :: Applicative f, Traversable t => t a ~> (TypeRep f, a -> f b) -> f (t b) Rule: t(u['fantasy-land/traverse'](F, x => x)) is equivalent to u['fantasy-land/traverse'](G, t) for any t such that t(a)'fantasy-land/map' is equivalent to t(a'fantasy-land/map') (naturality) Issue: definition part (a -> f b) is not equal to rule part (x => x)

davidchambers commented 4 years ago

@Ne4to777, are you saying that x => x cannot be a member of a -> f b? What if we were to make the following substitutions?

-- replace ‘a’ with ‘Array Number’
Array Number -> f b

-- replace ‘f’ with ‘Array’
Array Number -> Array b

-- replace ‘b’ with ‘Number’
Array Number -> Array Number
Ne4to777 commented 4 years ago

You are right. Tanks.

davidchambers commented 4 years ago

No problem. :)

rpominov commented 4 years ago

Even more common case when x => x is valid is when you already have applicatives inside your traversable. In other words your a happen to be f b.