These are chat archives for ramda/ramda

2nd
Oct 2015
Scott Sauyet
@CrossEye
Oct 02 2015 01:07
@scott-christopher: Is that really possible? map(g) would cause the Set to reduce in size only if Ǝ s1, s2 ∈ Domain(g) such that g(s1) = g(s2). If these exist, then compose(f, g)(s1) = f(g(s1)) = f(g(s2)) = compose(f, g)(s2), so map(compose(f, g)) would also reduce the size. Or am I missing something?
Scott Christopher
@scott-christopher
Oct 02 2015 01:14
Yeah, the more I think about it, I think you're right.
I did find an example which does demonstrate what I was referring to, but the AlwaysEq newtype is a bit absurd:
newtype AlwaysEq a = AlwaysEq { unAlwaysEq :: a }

instance Eq (AlwaysEq a) where
    _ == _ = True
instance Ord (AlwaysEq a) where
    _ `compare` _ = EQ

main :: IO ()
main = do
    let s = Set.fromList [1..3]
    print $ (Set.map unAlwaysEq . Set.map AlwaysEq) s
    print $ Set.map (unAlwaysEq . AlwaysEq) s
Scott Christopher
@scott-christopher
Oct 02 2015 01:26
Assuming Set honoured the equals method, you could achieve something similar with:
mappedValue = f => v => ({
  equals: x => x == f(v)
  unmap: v
})
let f = m => m.unmap
let g = mappedValue(R.T)

let s = Set(1, 2, 3)
map(compose(f, g), s); // Set(1, 2, 3)
compose(map(f), map(g))(s); // Set(<1, 2 or 3?>)
Scott Sauyet
@CrossEye
Oct 02 2015 01:38
Very interesting. This doesn't seem possible with native Set and it's reference equality, and perhaps not with a robust deepEqual, but when the type defines its own notion of equality, it is indeed possible. I stand corrected. (And still a bit startled!)
Scott Sauyet
@CrossEye
Oct 02 2015 02:04
"its reference equality" damn it!
Scott Christopher
@scott-christopher
Oct 02 2015 02:05
its and it's are all equal to me :D
Scott Sauyet
@CrossEye
Oct 02 2015 02:16
well damn it because in this case I can't even blame a phone and auto-correct. I'm on a laptop. :frowning:
Raine Virta
@raine
Oct 02 2015 06:30

@raine, R.complement(R.not) can also be pronounced Boolean. :wink2:

heh. I was trying to figure what was the opposite of R.not