Skip to content
Bartosz edited this page Sep 26, 2016 · 10 revisions

Does Reflex work with Haste?

Not at this time. Reflex does not currently work with Haste because Haste does not support weak references which are crucial to implementing the reflex FRP semantics efficiently.

References:

https://github.com/reflex-frp/reflex-dom/issues/86#issuecomment-241418181

Why doesn't Dynamic have Functor/Applicative/Monad instances

Reflex is scheduled to get these instances in version 0.5. As of this writing the implementation is mostly complete and is undergoing final polish and testing before release and is currently available on github in reflex's develop branch.

Can I use stack to build the Reflex/Reflex DOM application?

It is possible, but it's a bit of folklore at this moment. There are some examples out there, most notably:

https://github.com/tolysz/reflex-todomvc/

https://github.com/yamafaktory/reflex-starter

However, there might be issues preventing build from succeeding, in this case it's worth investigating the node version installed:

https://github.com/commercialhaskell/stack/issues/2495 https://github.com/commercialhaskell/stack/issues/1632

What do the types mean at a high level?

The three main types to understand in Reflex are Behavior, Event, and Dynamic.

Behavior

Behavior t a abstracts the idea of a value a at all points in time. It must be defined for all points in time and at any point you can look at the behavior and sample its value. If you need to represent something that does not have a value at all points in time, you should probably use Behavior t (Maybe a).

Event

Event t a abstracts the idea of something that occurs or is updated at discrete points in time. An example might be button clicks which would be Event t (), or key presses which might be Event t Char. Events are push oriented, i.e. they tell you when the value changes.

Dynamic

Dynamic t a is an abstraction that has a value at all points in time AND can notify you when its value is updated. They are essentially a tuple of an Event and a Behavior boxed up in a way that keeps everything consistent. They can be viewed as a step function over time, with the value changing at every occurrence.

What is the type variable t?

The t in many of the type signatures represents which Reflex timeline is in use. In the vast majority of use cases you will never need to care about t. Just use it where required and don't worry about needing to understand it.

Does reflex-dom support virtual-dom?

Reflex-dom doesn't need virtual-dom because it inherently keeps track of just what changed and only updates those things.

How can I associate some information when performing an XHR request and use it when processing a response event?

Use performRequestsAsync. This expects an event holding a Traversable of XhrRequests so using pair to attach additional data does the trick (as ((,) a) has Traversable instance).

Clone this wiki locally