[Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread AUGER Cédric
Hi all, I am an Haskell newbie; can someone explain me why there is no reported error in @legSome@ but there is one in @legSomeb@ (I used leksah as an IDE, and my compiler is: $ ghc -v Glasgow Haskell Compiler, Version 7.2.1, stage 2 booted by GHC version 6.12.3 ) What I do not understand is

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yves Parès
Perhaps you should give us the error the compiler give you. Plus: data LegGram nt t s = Ord nt = LegGram (M.Map nt [RRule nt t s]) will become invalid. Currently, such class constraints are ignored. You should remove the 'Ord nt' constraint and add it to you legSome function. (Maybe that's a

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Tue, Jan 3, 2012 at 5:43 PM, AUGER Cédric sedri...@gmail.com wrote: legSomeb :: LegGram nt t s - nt - Either String ([t], s) -- but without it I have an error reported legSomeb (LegGram g) ntV =   case M.lookup ntV g of     Nothing - Left No word accepted!     Just l - let sg = legSomeb

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Brandon Allbery
On Tue, Jan 3, 2012 at 05:17, Yucheng Zhang yczhan...@gmail.com wrote: subsome :: [RRule nt t s] - Either String ([t], s) It seems to me that the compiler is not sure the two 'nt' are equal. The ScopedTypeVariables can make the compiler believe they are equal. But ScopedTypeVariables is

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Tue, Jan 3, 2012 at 6:44 PM, Brandon Allbery allber...@gmail.com wrote: On Tue, Jan 3, 2012 at 05:17, Yucheng Zhang yczhan...@gmail.com wrote: subsome :: [RRule nt t s] - Either String ([t], s) It seems to me that the compiler is not sure the two 'nt' are equal. The ScopedTypeVariables

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Brandon Allbery
On Tue, Jan 3, 2012 at 05:50, Yucheng Zhang yczhan...@gmail.com wrote: On Tue, Jan 3, 2012 at 6:44 PM, Brandon Allbery allber...@gmail.com wrote: On Tue, Jan 3, 2012 at 05:17, Yucheng Zhang yczhan...@gmail.com wrote: subsome :: [RRule nt t s] - Either String ([t], s) It seems to me

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
As I understand it, both ways work. legSome ((LegGram g)::LegGram nt t s) ntV If you compile this without ScopedTypeVariables extension, GHC will remind you of it: Illegal signature in pattern: LegGram nt t s Use -XScopedTypeVariables to permit it So another solution is to avoid

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yves Parès
That is error-prone. Plus the code does not need ScopedTypeVariables. The real problem comes from the use of a class constraint on the LegGram data constructor. data LegGram nt t s = Ord nt = LegGram (M.Map nt [RRule nt t s]) Short answer: you *can't *add class constraints to an already declared

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Brandon Allbery
On Tue, Jan 3, 2012 at 06:35, Yucheng Zhang yczhan...@gmail.com wrote: legSome ((LegGram g)::LegGram nt t s) ntV If you compile this without ScopedTypeVariables extension, GHC will remind you of it: Illegal signature in pattern: LegGram nt t s Use -XScopedTypeVariables to

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Tue, Jan 3, 2012 at 7:46 PM, Brandon Allbery allber...@gmail.com wrote: Right, but I think this is conflating two aspects of ScopedTypeVariables and may not bring them into scope fully.  Although, that's a question for someone who understands ghc's type system far better than I do. I found

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Brandon Allbery
On Tue, Jan 3, 2012 at 06:43, Yves Parès limestr...@gmail.com wrote: That is error-prone. Plus the code does not need ScopedTypeVariables. The real problem comes from the use of a class constraint on the LegGram data constructor. data LegGram nt t s = Ord nt = LegGram (M.Map nt [RRule nt t

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Tue, Jan 3, 2012 at 7:49 PM, Yucheng Zhang yczhan...@gmail.com wrote: I found some descriptions of ScopedTypeVariables here: http://hackage.haskell.org/trac/haskell-prime/wiki/ScopedTypeVariables Sorry, I found just now a more up-to-date description in the GHC documentation:

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread AUGER Cédric
Thanks all, I finally give up to put Ord in the LegGram type. What was annoying me was that @legsome@ was in fact an instance of a class I defined. So I changed its signature to make it depend on Ord. That is not very nice, since at first glance, there could be implementations which does not

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Brent Yorgey
The other much simpler solution no one has mentioned yet is to just pull 'subsome' out as its own top-level declaration. Having such a big function nested locally within a 'let' is ugly anyway, and it makes it harder to test and debug than necessary. -Brent On Tue, Jan 03, 2012 at 05:44:01PM

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Wed, Jan 4, 2012 at 12:44 AM, Yves Parès limestr...@gmail.com wrote: Remove subsome type signature. You are redeclaring type variables which obviously cannot match those of legSome. This cannot work without scoped type variables (and ad-hoc foralls to bring them to scope, of course). That

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yves Parès
Brent is right. Separating functions is nicer to read and cleaner. Plus it enhances testability. I wonder why the redeclared type variables cannot match those of legSome? Try to put a totally wrong type to subsome, like subsome :: Int and tell us from the error what type is actually inferred.

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Wed, Jan 4, 2012 at 1:07 AM, Yves Parès limestr...@gmail.com wrote: Try to put a totally wrong type to subsome, like subsome :: Int and tell us from the error what type is actually inferred. The error is like Couldn't match type `nt' with `Int' `nt' is a rigid type variable bound

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Wed, Jan 4, 2012 at 1:38 AM, Yucheng Zhang yczhan...@gmail.com wrote: On Wed, Jan 4, 2012 at 1:07 AM, Yves Parès limestr...@gmail.com wrote: Try to put a totally wrong type to subsome, like subsome :: Int and tell us from the error what type is actually inferred. Sorry, I found I

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Wed, Jan 4, 2012 at 1:07 AM, Yves Parès limestr...@gmail.com wrote: I wonder why the redeclared type variables cannot match those of legSome? Try to put a totally wrong type to subsome, like subsome :: Int and tell us from the error what type is actually inferred. The actually inferred

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Bardur Arantsson
2012/1/3 Yucheng Zhangyczhan...@gmail.com (Hopefully being a little more explicit about this can help you understand where things are going wrong.) [--snip--] legSome :: LegGram nt t s - nt - Either String ([t], s) The 'nt' you see above legSome (LegGram g) ntV = case Main.lookup

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yucheng Zhang
On Wed, Jan 4, 2012 at 2:48 AM, Bardur Arantsson s...@scientician.net wrote: 'subsome' to a different type than the one you intended -- and indeed one which can't be unified with the inferred type. (Unless you use ScopedTypeVariables.) Thanks for the reply. Actually, my question is why the

[Haskell-cafe] Is the haddock generator on Hackage down?

2012-01-03 Thread Bardur Arantsson
Hi all, No Haddock documentation seems to have been generated on Hackage in the past few days. See e.g. http://hackage.haskell.org/package/copilot-2.0.3 or http://hackage.haskell.org/package/derive-2.5.5 Does anyone know if the cron job (or whatever) isn't running for some reason?

Re: [Haskell-cafe] space-efficient, composable list transformers [was: Re: Reifying case expressions]

2012-01-03 Thread Heinrich Apfelmus
Jan Christiansen wrote: On Jan 2, 2012, at 2:34 PM, Heinrich Apfelmus wrote: Without an explicit guarantee that the function is incremental, we can't do anything here. But we can just add another constructor to that effect if we turn ListTo into a GADT: data ListTo a b where

Re: [Haskell-cafe] Is the haddock generator on Hackage down?

2012-01-03 Thread Ross Paterson
On Tue, Jan 03, 2012 at 07:14:58PM +, Bardur Arantsson wrote: No Haddock documentation seems to have been generated on Hackage in the past few days. The machine's down, I think. I'll give it a kick tomorrow. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Experiments in Haskell Packaging

2012-01-03 Thread Chris Dornan
Hi Ryan, Ryan Grant [mailto:rgr...@rgrant.org] said: Are packages cabal-installed using --global? The packages that come with a compiler or Haskell Platform are installed --global. Every other package is installed with cabal, by default into the user's space. Is it mostly reliant on cabal or

Re: [Haskell-cafe] Solved but strange error in type inference

2012-01-03 Thread Yves Parès
Actually, my question is why the different type can't be unified with the inferred type? Because without ScopedTypeVariable, both types got expanded to : legSome :: *forall nt* t s. LegGram nt t s - nt - Either String ([t], s) subsome :: *forall nt* t s. [RRule nt t s] - Either String ([t],

Re: [Haskell-cafe] How to split this string.

2012-01-03 Thread Jonathan Frywater
If you're interested in learning parsec, RWH covered this topic in depth in Chapter 16, Choices and Errors: http://book.realworldhaskell.org/read/using-parsec.html. On Mon, Jan 2, 2012 at 3:44 AM, max m...@mtw.ru wrote: I want to write a function whose behavior is as follows: foo

[Haskell-cafe] GHC compilation issue: Working around bug #4374?

2012-01-03 Thread Sanket Agrawal
I am getting the compilation error below when building GHC 7.0.4 on RHEL5 (x86_64) – I configured make to point to ncurses and libgmp. I will appreciated pointers on how to work around the issue below. I don’t have root privileges. My apologies if this has already been discussed in this

Re: [Haskell-cafe] GHC compilation issue: Working around bug #4374?

2012-01-03 Thread Sanket Agrawal
My apologies for posting it here. Glasgow-haskell-users mailing list seems more relevant for this question. So, I am going to send it there instead, with a note about this cross-posting. On Tue, Jan 3, 2012 at 4:26 PM, Sanket Agrawal sanket.agra...@gmail.comwrote: I am getting the compilation