Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-23 Thread oleg
And HList paper left me with two questions. The first one is how much such an encoding costs both in terms of speed and space. And the second one is can I conveniently define a Storable instance for hlists. As I said before, I need all this machinery to parse a great number of serialized

Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-22 Thread AntC
Dmitry Vyal akamaus at gmail.com writes: On 10/19/2012 06:14 AM, AntC wrote: Roman Cheplyaka roma at ro-che.info writes: [snip] instance (Upcast a b, Upcast b c) = Upcast a c where upcast = (upcast :: b - a) . (upcast :: c - b) This is the offending instance. Remember, GHC only

[Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-19 Thread oleg
First of all, MigMit has probably suggested the parameterization of Like by the constraint, something like the following: data Like ctx = forall a. (ctx a, Typeable a) = Like a instance ALike (Like ALike) where toA (Like x) = toA x instance CLike (Like CLike) where toC (Like x) = toC x

Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-19 Thread Dmitry Vyal
On 10/19/2012 06:14 AM, AntC wrote: Roman Cheplyaka roma at ro-che.info writes: * Dmitry Vyal akamaus at gmail.com [2012-10-18 17:31:13+0400] On 10/18/2012 03:20 PM, MigMit wrote: Why do you need ALike x, BLike x etc.? Why not just Like u x? Hmm, looks like a nice idea. I tried it,

Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-19 Thread Dmitry Vyal
Second, all your examples so far used structural subtyping (objects with the same fields have the same type) rather than nominal subtyping of C++ (distinct classes have distinct types even if they have the same fields; the subtyping must be declared in the class declaration). For the structural

[Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-18 Thread Dmitry Vyal
Hello list! I've been experimenting with emulating subtyping and heterogeneous collections in Haskell. I need this to parse a binary representation of objects of a class hierarchy in C++ program. So far I implemented upcasting using a chain of type classes and now I'm playing with

Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-18 Thread MigMit
Why do you need ALike x, BLike x etc.? Why not just Like u x? Отправлено с iPhone Oct 18, 2012, в 14:36, Dmitry Vyal akam...@gmail.com написал(а): Hello list! I've been experimenting with emulating subtyping and heterogeneous collections in Haskell. I need this to parse a binary

Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-18 Thread Dmitry Vyal
On 10/18/2012 03:20 PM, MigMit wrote: Why do you need ALike x, BLike x etc.? Why not just Like u x? Hmm, looks like a nice idea. I tried it, unfortunately I can't cope with compiler error messages: tst.hs:32:15: Context reduction stack overflow; size = 201 Use -fcontext-stack=N to

Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-18 Thread Roman Cheplyaka
* Dmitry Vyal akam...@gmail.com [2012-10-18 17:31:13+0400] On 10/18/2012 03:20 PM, MigMit wrote: Why do you need ALike x, BLike x etc.? Why not just Like u x? Hmm, looks like a nice idea. I tried it, unfortunately I can't cope with compiler error messages: tst.hs:32:15: Context

Re: [Haskell-cafe] A yet another question about subtyping and heterogeneous collections

2012-10-18 Thread AntC
Roman Cheplyaka roma at ro-che.info writes: * Dmitry Vyal akamaus at gmail.com [2012-10-18 17:31:13+0400] On 10/18/2012 03:20 PM, MigMit wrote: Why do you need ALike x, BLike x etc.? Why not just Like u x? Hmm, looks like a nice idea. I tried it, unfortunately I can't cope with