infinite types

blaat blaat l4t3r@hotmail.com
Wed, 16 Jul 2003 14:01:36 +0200


Sorry if this mail starts a new thread. I am not subscribed to haskell-cafe 
and am new to hotmail.

Uhm, as far as the example goes. I was trying to define a small (shallow 
encoding of) a reactive systems language. Because I wanted to try something 
else than monads I defined the following recursive type for a reactive 
system.

  type R m = m -> Maybe (R m, [m])

Supposedly a reactive system is a system which may not take a message (the 
Maybe), or do take it and respond with an updated version of itself, and a 
sequence of outgoing messages.

For example, a copying machine might be defined as:

  id:R m
  id m = Just (id, [m])


A version for a ?Meally? machine embedding (always take an incoming message, 
and respond with one outgoing message) could be written as

type Meally i o = i -> (Meally i o, o)

where id is defined as

  id::Meally a a
  id m = (id, m)

I like the formalization because (a) it is concise, (b) structural 
composition operators can be defined trivially, (c) hides the state of a 
machine, (d) might possibly, in the long run, somewhere, even work out 
equally well as a monadic approach.

Does it make sense? Are there any known references to this approach?

Cheers,
  l4t3r

PS: Actually, I just realized this might be the co-algebraic approach, so I 
guess I am asking for a haskell which allows co-algebraic types.

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail