Looking for reliable heterogeneous vectors

Hello, everyone. I'm looking for reliable library or idea how to implement heterogenous vector properly. It may seem odd, but I want elements not only be different types but also functions, something like that, pseudocode: hvec [a b (c->d) [a] ...] -- can be any type let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]] So far I found *vector-heterogenous* package, but can't decide is it good to build on or create something on my own. Any thoughts and ideas are appreciated. Thanks.

Sure, you can do this easily with a GADT + DataKinds for convenient
indexing with lists. The construct you need is called a heterogeneous list,
or HList:
http://hackage.haskell.org/package/HList-0.3.0.1/docs/Data-HList-HList.html
But it's a nice exercise to implement it on your own anyway. If you need
"truly" heterogeneous lists where you can't even get the types of the
elements from the index typelist then you'll need to existentially hide the
types. This will simply be the same as HList without the indexing list.
Good luck
ex
On 1 December 2013 20:11, Sergey Bushnyak
Hello, everyone. I'm looking for reliable library or idea how to implement heterogenous vector properly. It may seem odd, but I want elements not only be different types but also functions, something like that, pseudocode:
hvec [a b (c->d) [a] ...] -- can be any type let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]]
So far I found *vector-heterogenous* package, but can't decide is it good to build on or create something on my own.
Any thoughts and ideas are appreciated. Thanks.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 12/01/2013 10:27 PM, Andras Slemmer wrote:
Sure, you can do this easily with a GADT + DataKinds for convenient indexing with lists. The construct you need is called a heterogeneous list, or HList: http://hackage.haskell.org/package/HList-0.3.0.1/docs/Data-HList-HList.html
But it's a nice exercise to implement it on your own anyway. If you need "truly" heterogeneous lists where you can't even get the types of the elements from the index typelist then you'll need to existentially hide the types. This will simply be the same as HList without the indexing list.
Good luck ex
On 1 December 2013 20:11, Sergey Bushnyak
mailto:sergey.bushnyak@sigrlami.eu> wrote: Hello, everyone. I'm looking for reliable library or idea how to implement heterogenous vector properly. It may seem odd, but I want elements not only be different types but also functions, something like that, pseudocode:
hvec [a b (c->d) [a] ...] -- can be any type let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]]
So far I found *vector-heterogenous* package, but can't decide is it good to build on or create something on my own.
Any thoughts and ideas are appreciated. Thanks.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Thank you for suggestions, I'll look into it.

On 1 December 2013 21:11, Sergey Bushnyak
Hello, everyone. I'm looking for reliable library or idea how to implement heterogenous vector properly. It may seem odd, but I want elements not only be different types but also functions, something like that, pseudocode:
hvec [a b (c->d) [a] ...] -- can be any type let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]]
So far I found *vector-heterogenous* package, but can't decide is it good to build on or create something on my own.
Take a look at fixed-vector-hetero[1]. It's not released yet but I hope I'll get in release ready shape by second half of December. It's an attepmt to provide API for working with arbitrary product types. General idea is to work with CPS represenation of data type [1] https://github.com/Shimuuar/fixed-vector-hetero

On 12/01/2013 10:29 PM, Aleksey Khudyakov wrote:
On 1 December 2013 21:11, Sergey Bushnyak
wrote: Hello, everyone. I'm looking for reliable library or idea how to implement heterogenous vector properly. It may seem odd, but I want elements not only be different types but also functions, something like that, pseudocode:
hvec [a b (c->d) [a] ...] -- can be any type let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]]
So far I found *vector-heterogenous* package, but can't decide is it good to build on or create something on my own.
Take a look at fixed-vector-hetero[1]. It's not released yet but I hope I'll get in release ready shape by second half of December.
It's an attepmt to provide API for working with arbitrary product types. General idea is to work with CPS represenation of data type
[1] https://github.com/Shimuuar/fixed-vector-hetero I like it, I'll try to play with it for couple of days and, probably, bother you a little bit with e-mails -)

Author of vector-heterogenous here. I tried to design the package to meet use cases like you describe, but fully admit that it's not perfect. It's missing a lot of the functions you might expect from the regular vector package (some of them are because I didn't need them, and some are because the best implementation is not obvious), and syntax is still a little awkward for my tastes. So if you have any ideas on improvements, I'd definitely be willing to incorporate them. Or if you have a great idea for a complete redesign of the package, I'd be happy to replace everything and let you take over. On Sun, Dec 1, 2013 at 12:11 PM, Sergey Bushnyak < sergey.bushnyak@sigrlami.eu> wrote:
Hello, everyone. I'm looking for reliable library or idea how to implement heterogenous vector properly. It may seem odd, but I want elements not only be different types but also functions, something like that, pseudocode:
hvec [a b (c->d) [a] ...] -- can be any type let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]]
So far I found *vector-heterogenous* package, but can't decide is it good to build on or create something on my own.
Any thoughts and ideas are appreciated. Thanks.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 12/02/2013 03:58 AM, Mike Izbicki wrote:
Author of vector-heterogenous here. I tried to design the package to meet use cases like you describe, but fully admit that it's not perfect. It's missing a lot of the functions you might expect from the regular vector package (some of them are because I didn't need them, and some are because the best implementation is not obvious), and syntax is still a little awkward for my tastes.
So if you have any ideas on improvements, I'd definitely be willing to incorporate them. Or if you have a great idea for a complete redesign of the package, I'd be happy to replace everything and let you take over.
On Sun, Dec 1, 2013 at 12:11 PM, Sergey Bushnyak
mailto:sergey.bushnyak@sigrlami.eu> wrote: Hello, everyone. I'm looking for reliable library or idea how to implement heterogenous vector properly. It may seem odd, but I want elements not only be different types but also functions, something like that, pseudocode:
hvec [a b (c->d) [a] ...] -- can be any type let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]]
So far I found *vector-heterogenous* package, but can't decide is it good to build on or create something on my own.
Any thoughts and ideas are appreciated. Thanks.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Mike, thank you for quick response, nice to hear you open for improvements. I'm also looking for this kind of package to be not only heterogeneous, but immutable and persistent, which leads to higher level of abstraction, something like *collection*. It will be nice to derive different types from it, like hvector, hlist etc. I'm doing small research now, if I'll understand that it's better to build upon your library or even reshape it I'll drop you an email.

I don't understand what you mean by immutable and persistant, because
vector-heterogenous is both of those! It just uses a standard boxed vector
as the backend and does some unsafeCoercing to get the types to line up.
On Sun, Dec 1, 2013 at 7:40 PM, Sergey Bushnyak wrote: On 12/02/2013 03:58 AM, Mike Izbicki wrote: Author of vector-heterogenous here. I tried to design the package to meet
use cases like you describe, but fully admit that it's not perfect. It's
missing a lot of the functions you might expect from the regular vector
package (some of them are because I didn't need them, and some are because
the best implementation is not obvious), and syntax is still a little
awkward for my tastes. So if you have any ideas on improvements, I'd definitely be willing to
incorporate them. Or if you have a great idea for a complete redesign of
the package, I'd be happy to replace everything and let you take over. On Sun, Dec 1, 2013 at 12:11 PM, Sergey Bushnyak <
sergey.bushnyak@sigrlami.eu> wrote: Hello, everyone. I'm looking for reliable library or idea how to
implement heterogenous vector properly. It may seem odd, but I want
elements not only be different types but also functions, something like
that, pseudocode: hvec [a b (c->d) [a] ...] -- can be any type
let hvec = hvec [ "stuff" 5 getUrl [1, 4, 5]] So far I found *vector-heterogenous* package, but can't decide is it good
to build on or create something on my own. Any thoughts and ideas are appreciated. Thanks. _______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe Mike, thank you for quick response, nice to hear you open for
improvements. I'm also looking for this kind of package to be not only
heterogeneous, but immutable and persistent, which leads to higher level of
abstraction, something like *collection*. It will be nice to derive
different types from it, like hvector, hlist etc. I'm doing small research now, if I'll understand that it's better to build
upon your library or even reshape it I'll drop you an email.
participants (4)
-
Aleksey Khudyakov
-
Andras Slemmer
-
Mike Izbicki
-
Sergey Bushnyak