Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-14 Thread Magicloud Magiclouds
OK. I am totally confused here. Why Couldn't match expected type `Jobs k e a' with actual type `M.Map k0 b0' 9|data JobInfo a e = (Exception e) = 10| JobInfo { jobId :: ThreadId 11| , result :: MVar (Either e a) } 12| 13|type Jobs k e a = (Ord k,

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-14 Thread Magicloud Magiclouds
Sorry, the last 'a' of line 22 is 'b'. On Thu, Jun 14, 2012 at 3:19 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: OK. I am totally confused here. Why Couldn't match expected type `Jobs k e a' with actual type `M.Map k0 b0'  9|data JobInfo a e = (Exception e) = 10|        

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-14 Thread Magicloud Magiclouds
And line 14, should be JobInfo a e. I must be too sleepy On Thu, Jun 14, 2012 at 3:30 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Sorry, the last 'a' of line 22 is 'b'. On Thu, Jun 14, 2012 at 3:19 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: OK. I am

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-14 Thread Arlen Cuss
Hi Magicloud, The indentation has been lost in the mail. Could you post your code (preferably without line numbers) on hpaste.org or similar? —A On Thursday, 14 June 2012 at 5:33 PM, Magicloud Magiclouds wrote: And line 14, should be JobInfo a e. I must be too sleepy On Thu, Jun

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-14 Thread Magicloud Magiclouds
Sorry, the full code is here: http://hpaste.org/69972 On Fri, Jun 15, 2012 at 7:09 AM, Arlen Cuss a...@len.me wrote: Hi Magicloud, The indentation has been lost in the mail. Could you post your code (preferably without line numbers) on hpaste.org or similar? —A On Thursday, 14 June 2012

[Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Magicloud Magiclouds
Hi, I've forgotten this. This is OK: type Job k a = Map k a And this is OK: {-# LANGUAGE RankNTypes #-} -- or LiberalTypeSynonyms? type Job = forall a. forall k. Map k a Then how to write it like this? type Job = Map k a -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com.

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Ivan Lazar Miljenovic
On 13 June 2012 19:59, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  I've forgotten this.  This is OK: type Job k a = Map k a  And this is OK: {-# LANGUAGE RankNTypes #-} -- or LiberalTypeSynonyms? type Job = forall a. forall k. Map k a  Then how to write it like this?

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Ismael Figueroa Palet
Do you want to hide the specific types of the job? Presumably to then define a type JobList = [Job] ? You can do that with the ExistentialQuantification extension. type Job = forall k a. Map k a type JobList = [Job] ?? Note you can't unpack the types k a once you have hidden them. But the

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Daniel Peebles
That doesn't require existential quantification, but it'll need Rank-2 types if you ever do anything with Job. Unfortunately, a universally quantified Job like what you wrote (or what Magicloud seems to want) is only inhabited by the empty Map. An existentially quantified Job, as you might get

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Yves Parès
Mmmmh... no, to do that you need ImpredicativeTypes (which is I believe about to be deprecated). You have to declare Job a data, not a type, and use ExistentialQuantification. 2012/6/13 Ismael Figueroa Palet ifiguer...@gmail.com Do you want to hide the specific types of the job? Presumably to

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Magicloud Magiclouds
Thank you all. I just want to wrap some complex types. So I learn from all info above, I still have to use forall explicitly On Wed, Jun 13, 2012 at 9:19 PM, Yves Parès yves.pa...@gmail.com wrote: Mmmmh... no, to do that you need ImpredicativeTypes (which is I believe about to be

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Magicloud Magiclouds
Hi there, Thanks for the reply. To be clear, all I want is to avoid having to type type variables all over the place. What should I do? My original code with RankNTypes and ImpredicativeTypes does not work The type Job = forall k a. M.Map k a works now. But function uses it does not.

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Arlen Cuss
(resending to café, turns out I wasn't subbed from this address.) Hi Magicloud, This is correct; because you've hidden the type-variables away by universally quantifying them, there's no more level of specificity you can get back *out* of them than just some kind of Map (Job = M.Map k b, where

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Magicloud Magiclouds
OK. I think I understand a little. I use Job here just wants to simplify the code. And since I provide the function as library, I cannot decide what exact type k is. What should I do? On Thu, Jun 14, 2012 at 11:23 AM, Arlen Cuss a...@len.me wrote: (resending to café, turns out I wasn't subbed

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Ivan Lazar Miljenovic
On 14 June 2012 14:20, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: OK. I think I understand a little. I use Job here just wants to simplify the code. And since I provide the function as library, I cannot decide what exact type k is. What should I do? Do you know what the type

Re: [Haskell-cafe] What extension do I need to write type Job = Map k a?

2012-06-13 Thread Magicloud Magiclouds
I think I need to think this through On Thu, Jun 14, 2012 at 12:28 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 14 June 2012 14:20, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: OK. I think I understand a little. I use Job here just wants to simplify the