Re: [Haskell-cafe] can't figure out a type

2009-02-12 Thread John Lato
Hi Job, thanks for replying. Thanks for explaining this. I never really thought about the implications of kinds on type classes, and it's all much more clear now. The first version, with only one parameter, almost works, except that some instances (e.g. uvector, storablevector) have further

Re: [Haskell-cafe] can't figure out a type

2009-02-12 Thread John Lato
One clarification. That is, I could write map with the cNull/cCons implementation already suggested, but I couldn't do: instance Chunkable Data.StorableVector.Vector el where ... cMap = Data.StorableVector.map which is what I really want. However, I just realized that I should be able to

[Haskell-cafe] can't figure out a type

2009-02-11 Thread John Lato
Hello, I'm working on some code like the following: class Chunkable c el | c - el where cLength :: c - Int cHead :: c - Maybe el I want to be able to map over this type, like this: cMap :: Chunkable c' el' = (el - el') - c - c' but this isn't quite right. c' shouldn't be any

Re: [Haskell-cafe] can't figure out a type

2009-02-11 Thread Job Vranish
What do you mean by parameterized over a different type? will c have a kind of * - * ? I don't think it has to be for what you want to work, but the idea of same instance will go out the window. Do you have a small usage example? On Wed, Feb 11, 2009 at 11:52 AM, John Lato jwl...@gmail.com

Re: [Haskell-cafe] can't figure out a type

2009-02-11 Thread John Lato
Hi Job, Thanks for answering. What I'm trying to do is probably very simple, and I think the biggest problem is that I don't fully understand kinds yet. Here's an example instance: instance Chunkable [a] a where cmap = map --etc. In the class I wrote, c has kind * (e.g. [a]), but then I

Re: [Haskell-cafe] can't figure out a type

2009-02-11 Thread Ryan Ingram
You can do this with another type class. class (Chunkable c1 el1, Chunkable c2 el2) = ChunkMap c1 el1 c2 el2 where cMap :: (el1 - el2) - c1 - c2 instance ChunkMap [a] a [b] b where cMap = map If you want to assert that c1 and c2 are really related, you can add functional dependencies to

Re: [Haskell-cafe] can't figure out a type

2009-02-11 Thread Job Vranish
I think what you probably want is something like this: class Chunckable c where cLength :: c el - Int cHead :: c el - Maybe el cMap :: (a - b) - c a - c b instance Chunckable [] where cLength [] = 0 cLength (x:xs) = 1 + cLength xs cHead [] = Nothing cHead (x:xs) = Just x cMap =