On Tue, Jan 3, 2012 at 6:44 PM, Brandon Allbery <[email protected]> wrote:
> On Tue, Jan 3, 2012 at 05:17, Yucheng Zhang <[email protected]> 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 enabled already.
>
Sorry, I meant actually using ScopedTypeVariables as in the first function,
which compiles well:
legSome :: LegGram nt t s -> nt -> Either String ([t], s)
-- ^^^^^^^^^^^^^^
-- isn't this redundant?
-- vvvvvvvvvvvvvv
legSome ((LegGram g)::LegGram nt t s) ntV =
case M.lookup ntV g of
Nothing -> Left "No word accepted!"
Just l -> let sg = legSome (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)
in
case makeWord r of
Right (ll, mm) -> Right (ll, sem mm)
Left err -> subsome l
in subsome l
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe