These are chat archives for ramda/ramda

Oct 2015
Scott Sauyet
Oct 02 2015 01:07 UTC
@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
Oct 02 2015 01:14 UTC
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 $ ( unAlwaysEq . AlwaysEq) s
    print $ (unAlwaysEq . AlwaysEq) s
Scott Christopher
Oct 02 2015 01:26 UTC
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
Oct 02 2015 01:38 UTC
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
Oct 02 2015 02:04 UTC
"its reference equality" damn it!
Scott Christopher
Oct 02 2015 02:05 UTC
its and it's are all equal to me :D
Scott Sauyet
Oct 02 2015 02:16 UTC
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
Oct 02 2015 06:30 UTC

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

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