[Haskell-cafe] Is this functional reactive programming

Kim-Ee Yeoh ky3 at atamo.com
Mon May 11 03:58:55 UTC 2015


On Mon, May 11, 2015 at 7:36 AM, Clinton Mead <clintonmead at gmail.com> wrote:

> The "letSTRef" is what's new. The value it returns can change based on the
> parts that make up it's function changing.


Certainly that sounds very close to FRP, which propounds the concept of
_time-varying_ values.

I understand this syntax above isn't going to work (I'd have to use
> applicative at least I'd imagine) but my main question is that does
> something like this exist?
>

Let's assume you want to adopt the classic effectful approach to FRP. Now
when you write:

x <- newSTRef 2
y <- newSTRef 3
z <- letSTRef (x + y)

you're really working in a pure fragment. Moreover, letSTRef, while
attractive, is sort of on the wrong track.

Suppose we have two time-varying values mouseX and mouseY. They are both at
least applicative values, i.e. f Int for some applicative, possibly even
monadic, functor f.

They are also primitive, like the way a Haskell Int is primitive and
involves hardware-wired details, meaning you'll do the actual implement at
a lower level than the following:

We have a Euclidean distance function dist :: Int -> Int -> Int.

To track the distance of the mouse pointer from the origin, we'd write
liftA2 dist mouseX mouseY :: f Int, thus deriving another time-varying Int.

Does this help clarify?


-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150511/127b024d/attachment.html>


More information about the Haskell-Cafe mailing list