Corentin Dupon wrote about essentially the read-show problem:
class (Typeable e) = Event e
data Player = Player Int deriving (Typeable)
data Message m = Message String deriving (Typeable)
instance Event Player
instance (Typeable m) = Event (Message m)
viewEvent ::
Dear All,
I would like to announce a new package called 'hsqml' [1].
HsQML provides a Haskell binding to the Qt Quick framework. It allows
you to write graphical applications where the front-end is written in Qt
Quick's QML language (incorporating JavaScript) and the back-end is
written in
Hi,
is there any way to perform a destructive update on a plain ADT?
Hi Milan, perhaps this is a dumb question, but given that you're using a lazy
functional language: why do you want to do destructive updates at all?
Perhaps you'd be better off using an imperative/object-oriented
On 11-09-12 08:53, o...@okmij.org wrote:
Corentin Dupon wrote about essentially the read-show problem:
class (Typeable e) = Event e
data Player = Player Int deriving (Typeable)
data Message m = Message String deriving (Typeable)
instance Event Player
instance (Typeable m) =
Thanks Martijn, Oleg and Ryan for your kind replies!
@Ryan and Martijn: I considered putting the viewEvent in the typeclass, but
I figured out that would break the separation of concerns. Indeed this
typeclass Event belongs to the inner engine, while the display is done in
another component (not
On Tue, Sep 11, 2012 at 3:39 PM, Corentin Dupontwrote:
@Oleg: Yes the set of events is closed and I would be much happier with a
GADT! But no matter how hard I tried I couldn't manage.
Here is the full problem:
*{-# LANGUAGE ExistentialQuantification, TypeFamilies, DeriveDataTypeable
#-}
Yes.
That's fantastic! This GADT is the missing piece of my puzzle. I
transformed a bit your solution, polluting it with some classes instances
and fleshing the functions:
*data Player = Arrive | Leave deriving (Show, Typeable, Eq)
data Message m = Message String deriving (Show, Typeable, Eq)
I finally come up with this version, which allows to do pattern matching
against the events.
I'm sure it could be cleaned a bit, but it think the idea is there.
I would like to thank again everybody on this list, that's very friendly
and helpful!
Corentin
*{-# LANGUAGE ExistentialQuantification,
Hello,
I am currently trying to rewrite the Graphics.Pgm library from hackage
to parse the PGM to a lazy array. The current implementation parses it
straight to UArray, which is strict.
The behaviour I want to achieve is like this: I want the program when
compiled to read from a file, parsing
Is it possible to capture more than one constructor in a single
pattern matching?
I mean, is it possible to generalize the following pattern matching of
A and B to a single branch?
g f C = [f C]
g f v@(A _ n) = f v : g n
g f v@(B _ n) = f v : g n
For example:
g f C = [f C]
g f v@(A|B _ n) = f v
I'm not sure I understand
On Tue, Sep 11, 2012 at 11:06 AM, Corentin Dupont
corentin.dup...@gmail.com wrote:
Yes.
That's fantastic! This GADT is the missing piece of my puzzle. I transformed
a bit your solution, polluting it with some classes instances and fleshing
the functions:
data
Hi David,
that may be also a way to go. I've also looked into this way (view
patterns), unfortunately it seems that I will be obliged to maintain 2
parallel structures:
for each Event instance, I will have to add a ViewEvent element as well
carrying the same information:
instance Event Time where
On Tue, Sep 11, 2012 at 6:46 PM, David Menendez wrote:
Mixing GADTs and Typeable seems like a bad idea. If you really don't
want to put viewEvent in the Event typeclass, but the class of events
is closed, you could use a GADT to witness the event type.
On Tue, Sep 11, 2012 at 7:03 PM,
On Tue, Sep 11, 2012 at 9:36 AM, Eric Velten de Melo
ericvm...@gmail.com wrote:
Any thoughts? Hopefully I'm not saying anything really stupid.
You can intersperse decoding errors in the output, e.g. output is
[Either Error DecodedChunk]. Then all the processors have to deal
with it, but if you
That's very interesting.
One problem is, if the set of event is closed, the set of possible data
types is not (the user can choose any data type for a Message callback for
example). I think this can be solved using a class instead of a GADT for
Type. One can also use a type witness?
On Tue, Sep
Use a tuple: (Result,Maybe Error) rather than an Either. Do everything
lazily, and in the case of an error, undo the result.
-- Původní zpráva --
Od: Eric Velten de Melo ericvm...@gmail.com
Datum: 11. 9. 2012
Předmět: [Haskell-cafe] Either Monad and Laziness
Hello,
I am
On Tue, Sep 11, 2012 at 9:18 PM, Corentin Dupont wrote:
That's very interesting.
One problem is, if the set of event is closed, the set of possible data
types is not (the user can choose any data type for a Message callback for
example). I think this can be solved using a class instead of a
I've seen this asked before, and I think some languages support it (ML
maybe?). One way to do this is with view patterns:
g f C = [f C]
g f (getVN - (v, n)) = f v : g f n
getVN v@(A _ n) = (v, n)
getVN v@(B _ n) = (v, n)
(I changed the recursive call to g - figured you meant passing along f)
Let me see if I understand. You have events of different sorts: events
about players, events about timeouts, events about various
messages. Associated with each sort of event is a (potentially open)
set of data types: messages can carry payload of various types. A
handler specifies behavior of a
19 matches
Mail list logo