[Haskell-cafe] Inferred type less polymorphic than expected
Joel Reymont
joelr1 at gmail.com
Tue Nov 8 12:53:38 EST 2005
This gets me pretty close. I now have to figure out how to return a
PU Props instead of a PU [Prop] which is what it's returning. Still,
it's a huge step forward.
props :: Props -> PU Props
props m = props' $ sort $ M.toList m
where props' [] = lift []
props' ((_, (_, x)):xs) =
wrap (\(a, b) -> a : b,
\(a : b) -> (a, b))
(pair (prop x) (props' xs))
./Script/Prop.hs:82:10:
Couldn't match `Props' against `[Prop]'
Expected type: PU Props
Inferred type: PU [Prop]
In the expression: props' $ (sort $ (Data.Map.toList m))
In the definition of `props':
props m = props' $ (sort $ (Data.Map.toList m))
where
props' [] = lift []
props' ((_, (_, x)) : xs)
= wrap (\ (a, b) -> a : b, \ (a : b) ->
(a, b)) (pair (prop x) (props' xs))
Big thanks to Andrew and Malcolm on #haskell for pointing me in the
right direction!
Thanks, Joel
On Nov 8, 2005, at 5:23 PM, Andrew Pimlott wrote:
> You might have better luck getting if you send a complete example,
> since
> it's hard for me to figure out exactly what this code is supposed
> to do.
> However, I'll take a quick stab.
>
> On Tue, Nov 08, 2005 at 04:46:56PM +0000, Joel Reymont wrote:
>> props :: Props -> PU Props
>> props m = props' $ sort $ M.toList m
>> where props' [] = lift []
>> props' ((_, (Attr _ _ pp := _)):xs) =
>> wrap (\(a, b) -> a : b,
>> \(a : b) -> (a, b))
>> (pair pp (props' xs))
>>
>>
>> ./Script/Prop.hs:80:10:
>> Inferred type is less polymorphic than expected
>> Quantified type variable `a' is mentioned in the environment:
>> props' :: [(a1, Prop)] -> PU [a] (bound at ./Script/Prop.hs:
>> 79:10)
>
> Recall that pp is a (PU a) for some a. However, the inferred type for
> props' is fully polymorphic in a. It might help first of all to write
> down the type you expect for props', and then add type annotations to
> different pieces until you find the one that's going awry.
>
> Andrew
--
http://wagerlabs.com/
More information about the Haskell-Cafe
mailing list