[Haskell-cafe] Solved but strange error in type inference
yczhang89 at gmail.com
Tue Jan 3 11:17:11 CET 2012
On Tue, Jan 3, 2012 at 5:43 PM, AUGER Cédric <sedrikov at 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 (LegGram (M.delete ntV g))
> subsome :: [RRule nt t s] -> Either String ([t], s)
> subsome  = Left "No word accepted!"
> subsome ((r,sem):l) =
> let makeWord  = Right (,)
> makeWord ((NT nnt):ll) =
> do (m, ss) <- sg nnt
> (mm, sss) <- makeWord ll
> return (m++mm, ss:sss)
> makeWord ((T tt):ll) =
> do (mm, sss) <- makeWord ll
> return (tt:mm, sss)
> case makeWord r of
> Right (ll, mm) -> Right (ll, sem mm)
> Left err -> subsome l
> in subsome l
I found it compiling well if removing this line:
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.
More information about the Haskell-Cafe