[Haskell-cafe] Is it possible to change the environment (reader) in applicative style?

MarLinn monkleyon at gmail.com
Wed Sep 12 16:57:16 UTC 2018


> Yes, the example with Let Name Term Term is what I was experimenting with.
> About "eval t2 . (update' <*> pure s <*> eval t1)":
> Well I was following applicative style as "Applicative Programming
> with Effects" by Conor McBride
> I did not consider this line applicative because of the (.) operator;
> I am trying to get away with just `pure` and `<*>` -- to be more
> precise, the K and S combinators.
> So the question becomes: can we implement the environment modification
> operation without resorting to function composition?

Note that for (->), (<$>)= (.).


	eval t2 . bracket ≡ eval t2 <$> bracket

Note also that by definition (<$>) = (<*>) . pure and therefore

	eval t2 <$> bracket ≡ pure (eval t2) <*> bracket

So more precisely

	eval t2 . (update' <*> pure s <*> eval t1) ≡ pure (eval t2) <*> (update' <*> pure s <*> eval t1)

which, as per your requirements, uses only pure and (<*>) (plus function 
application and brackets).

Is this what you where going for? If not I think we would need more 
precisely defined requirements to help further.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180912/a2134580/attachment.html>

More information about the Haskell-Cafe mailing list