I'm trying to get around my problem (still stuck...).<br>I have really to call a function like this:<br>triggerEvent :: (Typeable e, Show e, Eq e) => Event e -> EventData e -> State Game ()<br><br>This function simply execute an event given the corresponding data and change the state of the game.<br>
Now as explained my web framework won't accept random types (like "e") to be passed around.<br>So I said to myself "OK, so let's store the events in a list and ask the gui to just give me the number of the event".<br>
So I have an heterogeneous list of events [EventWrap]:<br><br>data EventWrap where<br> EW :: (Typeable e, Show e, Eq e) => {eventNumber :: Int, event :: Event e} -> EventWrap<br><br>Do you think this solution can lead me somewhere?? I have actually doubts I can find back my "Event e" from the list because of the implicit forall in the GADT.....<br>
<br>Thanks,<br>Corentin<br><br><br><div class="gmail_quote">On Wed, Oct 24, 2012 at 3:37 PM, Chris Smith <span dir="ltr"><<a href="mailto:cdsmith@gmail.com" target="_blank">cdsmith@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><p dir="ltr">"Corentin Dupont" <<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>> wrote:<br>
> I could ask my user to make his new type an instance of a class as suggested by Alberto...</p>
</div><p dir="ltr">If you are working with unknown types, then your options are: (a) constrain to some type class, or (b) have your clients pass in functions to operate on the type alongside the values. Actually the first is just a special case of the second with syntactic sugar...</p>
</blockquote></div><br>