[Haskell-cafe] Help me refactor this type!

Luke Palmer lrpalmer at gmail.com
Thu Apr 24 20:06:23 EDT 2008

On Thu, Apr 24, 2008 at 11:10 PM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> More FRP stuff: a new type for Future that came to me in an
>  inspiration this morning.  But it's ugly and I need someone with
>  better theoretical underpinnings than me to tell me what I've really
>  built :)
>  data Future t a =
>     Known t a
>   | Unknown (t -> IO (STM (Maybe (Future t a))))

This looks similar to my friend the "free monad over exponentiation",
or Suspend, which I also discovered while experimenting with FRP.
After experimenting a bit, I found that the following variant lead to
more elegant implementations of the same things:

  newtype SuspendT v m a
    = SuspendT (m (Either a (v -> SuspendT v m a)))

Implemented pretty fully here:

I'm not quite sure whether you can make it have all the capabilities
yours does (there is no STMT...).


More information about the Haskell-Cafe mailing list