These are chat archives for ramda/ramda
MayBewe can put it inside an
Array, which is clever. There is also another case that
R.aphandles — https://github.com/ramda/ramda/blob/v0.21.0/src/ap.js#L30-L33 This is when it considers the applicative to be a function. What's the intuition there?
@CrossEye thats for that !
If I am not mistaken the only difference between the reader and state monad is the fact that with state you can both read and write - but not with reader
Reader.ask.chain(env => Reader.of(configureDb(env.dbConn)));
askis just a
Readerinstance that provides access to the whole environment of the
Reader.of = a => Reader(_ => a)
Reader.ask = Reader(a => a)
ofcreates an environment from the provided value, ignoring the provided value.
_just represents an argument that isn't used.
() => x
constant = 5 a = -> constant
so when you do
you are just calling .of ?
Readeris basically a data-type to model functions.
Readershould just be a function.
but what does this mean
Readeris ready to be executed, you provide the
Readeris basically just a way to compose a bunch of functions together.
instance Functor ((->) r) where fmap = (.) instance Applicative ((->) a) where pure = const (<*>) f g x = f x (g x) instance Monad ((->) r) where f >>= k = \ r -> k (f r) r
IOtypes (at least how we've constructed them in JS) are ways of describing
Monadbehaviours over functions.
(fmap fmap (+)) 10 $ Just 10:smile:
Readermodels a functions of
r -> a, while
IOis effectively specialised for
() -> a.
Writeris conceptually a way to log something during a computation. In practice it just keeps the logged value along with the value returned from the computation in a tuple. When something new is logged, is is joined with the existing logged value using its monoid behaviour (e.g.
concatin fantasy-land terminology).
Statein a single type.