Re: Easily generating efficient instances for classes

From: Christian H?ner zu Siederdissen
Hi,
I am thinking about how to easily generate instances for a class. Each instance is a tuple with 1 or more elements. In addition there is a second tuple with the same number of elements but different type. This means getting longer and longer chains of something like (...,x3*x2,x2,0).
- template haskell? - CPP and macros?
Consider arrays with fast access like Data.Vector, but with higher dimensionality. Basically, I want (!) to fuse when used in Data.Vector code.
(shameless plug) You may want to look at my AdaptiveTuple package, which does something very similar to this. I used Template Haskell because AFAIK neither generic approaches nor DrIFT/Derive will generate data decls. If all you need are the instances, then DrIFT or Derive would be my recommendations. Cheers, John

Hi
Derive generates declarations - they can be instances, classes, data
types, functions, type synonyms etc.
Thanks, Neil
On Mon, Mar 1, 2010 at 10:32 AM, John Lato
From: Christian H?ner zu Siederdissen
Hi,
I am thinking about how to easily generate instances for a class. Each instance is a tuple with 1 or more elements. In addition there is a second tuple with the same number of elements but different type. This means getting longer and longer chains of something like (...,x3*x2,x2,0).
- template haskell? - CPP and macros?
Consider arrays with fast access like Data.Vector, but with higher dimensionality. Basically, I want (!) to fuse when used in Data.Vector code.
(shameless plug) You may want to look at my AdaptiveTuple package, which does something very similar to this. I used Template Haskell because AFAIK neither generic approaches nor DrIFT/Derive will generate data decls.
If all you need are the instances, then DrIFT or Derive would be my recommendations.
Cheers, John _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Thanks everybody for the answers. Right now, it looks like this: the indextype is abstracted out and I plan for Data.Ix and my own Data.FastIx (or however to call it). As I don't plan on creating all instances myself, Neils derive package looks good -- once I understand it completely; which I need to as I need instances of my own class. Is there a tutorial on creating instances for own stuff, or should I go by the examples like Functor? The code in AdaptiveTuple has one advantage: it looks easier to get started producing instances. (No need to get to know another package). Btw. it is a bit disappointing (for me) that Data.Ix is almost as fast as my FastIx ;-) (as in: most people don't care about the difference) Something else: was there a resource about library naming? otherwise it is going to be vector-ixtables (someone a better idea?) Thanks again, Christian On 03/02/2010 02:30 PM, Neil Mitchell wrote:
Hi
Derive generates declarations - they can be instances, classes, data types, functions, type synonyms etc.
Thanks, Neil
On Mon, Mar 1, 2010 at 10:32 AM, John Lato
wrote: From: Christian H?ner zu Siederdissen
Hi,
I am thinking about how to easily generate instances for a class. Each instance is a tuple with 1 or more elements. In addition there is a second tuple with the same number of elements but different type. This means getting longer and longer chains of something like (...,x3*x2,x2,0).
- template haskell? - CPP and macros?
Consider arrays with fast access like Data.Vector, but with higher dimensionality. Basically, I want (!) to fuse when used in Data.Vector code.
(shameless plug) You may want to look at my AdaptiveTuple package, which does something very similar to this. I used Template Haskell because AFAIK neither generic approaches nor DrIFT/Derive will generate data decls.
If all you need are the instances, then DrIFT or Derive would be my recommendations.
Cheers, John _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Hi Christian,
No good examples I'm afraid. There are a few notes in README.txt (I
just pushed a few more notes). If you follow the process I'd welcome
any improvements to the documentation.
Thanks, Neil
On Tue, Mar 2, 2010 at 1:50 PM, Christian Hoener zu Siederdissen
Thanks everybody for the answers.
Right now, it looks like this: the indextype is abstracted out and I plan for Data.Ix and my own Data.FastIx (or however to call it).
As I don't plan on creating all instances myself, Neils derive package looks good -- once I understand it completely; which I need to as I need instances of my own class. Is there a tutorial on creating instances for own stuff, or should I go by the examples like Functor?
The code in AdaptiveTuple has one advantage: it looks easier to get started producing instances. (No need to get to know another package).
Btw. it is a bit disappointing (for me) that Data.Ix is almost as fast as my FastIx ;-) (as in: most people don't care about the difference)
Something else: was there a resource about library naming? otherwise it is going to be vector-ixtables (someone a better idea?)
Thanks again, Christian
On 03/02/2010 02:30 PM, Neil Mitchell wrote:
Hi
Derive generates declarations - they can be instances, classes, data types, functions, type synonyms etc.
Thanks, Neil
On Mon, Mar 1, 2010 at 10:32 AM, John Lato
wrote: From: Christian H?ner zu Siederdissen
Hi,
I am thinking about how to easily generate instances for a class. Each instance is a tuple with 1 or more elements. In addition there is a second tuple with the same number of elements but different type. This means getting longer and longer chains of something like (...,x3*x2,x2,0).
- template haskell? - CPP and macros?
Consider arrays with fast access like Data.Vector, but with higher dimensionality. Basically, I want (!) to fuse when used in Data.Vector code.
(shameless plug) You may want to look at my AdaptiveTuple package, which does something very similar to this. I used Template Haskell because AFAIK neither generic approaches nor DrIFT/Derive will generate data decls.
If all you need are the instances, then DrIFT or Derive would be my recommendations.
Cheers, John _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (3)
-
Christian Hoener zu Siederdissen
-
John Lato
-
Neil Mitchell