These are chat archives for ramda/ramda

12th
Dec 2018
Rakesh Pai
@rakeshpai
Dec 12 2018 02:51
@CrossEye Ah, thanks! I actually wasn't aiming for fantasy-land compatibility, since this is just an introduction to the concepts, and not really rigorous. But if it's easy to fix to be compatible with the spec, I'll be happy to. (I'm actually not very familiar with the fantasy-land specs - I don't know all the jargon yet to fully understand it.)
Maybe.of ensures that you never get a Just(null). But is that incorrect?
Ian Hofmann-Hicks
@evilsoft
Dec 12 2018 03:50
You should be allowed to get a Just(null), it need to lift ANY javascript value, untouched and unchecked. for it to be either a Monad or Applicative Functor
Many people create helper functions like fromNil or safe that take a value or predicate function to determine what instance is used (Just or Nothing)
Ian Hofmann-Hicks
@evilsoft
Dec 12 2018 03:55
So it is beyond just Fantasy Land compatible, it is not a Monad or Applicative by any standard.
Rakesh Pai
@rakeshpai
Dec 12 2018 03:56
Thanks @evilsoft. So, if I understand correctly, just a helper function should do the job, and having a Maybe.of returning either a Just or Nothing is incorrect?
(Thanks for your videos! Many hours have been spent watching your videos. :) )
Ian Hofmann-Hicks
@evilsoft
Dec 12 2018 03:58
of should always return a Just to make all the required diagrams commute
Oh np. Glad at least one person watches them
Rakesh Pai
@rakeshpai
Dec 12 2018 04:01
Understood, though I think there's lots of detail here I'm not familiar with. I'll pick it up. :)
I've recommended your videos to several people, so it's more than one for sure. :)
Ian Hofmann-Hicks
@evilsoft
Dec 12 2018 04:38
Also unless you have a means of constructing an instance without the null check, you actually do not even have a functor. Which is The basis for both Monads and applicative
Rakesh Pai
@rakeshpai
Dec 12 2018 04:47
Got it. I think that's the point @CrossEye was making as well. Cool. I'll be sure to point out that my implementation isn't rigorous at all, and is just to demonstrate concepts. Also I'll be sure to catch up on some reading.
Scott Sauyet
@CrossEye
Dec 12 2018 14:01

Yes, that's the same point. The fix is not hard, either. Just write another function (isNil, safe, etc., or I've seen it simply called maybe) that creates a Just or a Nothing the way your current Maybe.of does it, and let Maybe.of be val => Just(val), even if val is nil.

Then, for instance, head == (arr) => maybe(arr[0]) and you have a safe head.

Rakesh Pai
@rakeshpai
Dec 12 2018 14:54
Perfect. That matches my understanding. Thanks, @CrossEye!
Julien Gonzalez
@customcommander
Dec 12 2018 15:21
@CrossEye My question on SO has been reopened
Looking forward to your thoughts :)
Scott Sauyet
@CrossEye
Dec 12 2018 18:41
@customcommander: Responded: https://stackoverflow.com/a/53749392/
Julien Gonzalez
@customcommander
Dec 12 2018 18:57
Thx