OK. I've included the 2nd part of the proposed solution in the same pull request. It allows the same function to be used for the Lambda1 carrying dependencies as well as a regular closure (purescript lambda).
In your Lamba.test.purs I have a mapd
(map with dependencies) where both pieces of code type check.
let c = mapd (
lambda1
((\x -> x + (sample b)) :: Int -> Int)
[dep b]
)
(toStream a)
Typechecks, and also
let c = mapd
((\x -> x + (sample b)) :: Int -> Int)
(toStream a)
Typechecks too.
It means instead of having both snapshotLambda2
and snapshot
. You can have just snapshot
instead as one implementation and it will work in both styles.
mapd
comes from the typeclass SodiumFunctor
which in an odd way, is slightly more general than Functor
. Meaning you can do this:
class Functor Stream where
map = mapd
Which will squeeze out a tiny bit more code re-use.