[Haskell-cafe] What's a thread doing / Erlang-style processes / Message passing

Bulat Ziganshin bulatz at HotPOP.com
Wed Dec 7 02:49:41 EST 2005

Hello Joel,

Tuesday, December 06, 2005, 8:30:32 PM, you wrote:

JR> Assuming I typed events like that I think I would need a typed sink  
JR> for them as well. I only have one sink for the events and that is my  
JR> message queue.

i don't understand you. remember that i'm not native English speaker :)

JR> I expect users to want User X, User Y, User Z within  
JR> the same module and that's why I used Dynamic.

if you can define all these datatags (X, Y and Z) in one type then you
can use pattern matching:

data UserEvent = X ... | Y ... | Z ...

if not - then can't. of course, you can use this "subtyping trick"
several times, but it is not very interesting:

data Event a = ... | User a
data UserEvent1 a = X ... | User2 a
data UserEvent2 a = Y ... | User3 a

send chan (User $ User2 $ Y)  -- type of expression inside brackets is
"Event (UserEvent1 (UserEvent2 a))", where a is unspecified

or you can define

data Event a b c = ... | User1 a | User2 b | User3 c

but this is also bad :(

you can also use classes, but Dynamic actually does the same, and this
gives you no ability to do pattern-matching

Best regards,
 Bulat                            mailto:bulatz at HotPOP.com

More information about the Haskell-Cafe mailing list