[Haskell-cafe] Hiding type variables from the signature?

Olaf Klinke olf at aatal-apotheke.de
Fri Jun 3 04:58:17 UTC 2022


> λ f = deasilsB . deasilsA
> 
> <interactive>:2:1: error:
>     • Could not deduce: Dress seed0 peels0 ~ Dress seed peels
> ```
> 
> What is going on? How can I have my `deasils`?
> 
> I tried attaching all kinds of type annotations, but nothing works so far. I do
> not even understand the problem. How is it that an expression can be typed, but
> cannot be assigned to a name?
> 
> You can see the complete code at the gist [1].
> 
> [1]: https://gist.github.com/kindaro/6056f753bcf356ced96b817fee72533c/2823ec2792f089de65abfb0a0bf677f96432fff4

The given type annotation for desilsA uses forall, which suggests you
want to use ScopedTypeVariables here. But for that feature to kick in,
you need to actually mention the scoped type variables in the function
body, which you don't. 

:t deasil . first squeeze
deasil . first squeeze
  :: (ForAll peels Functor,
      Squeezy' left a peels (Strip left a == '[])) =>
     (a, right) -> Squeezed peels (left, right)

You must use ScopedTypeVariables to constrain the type variable `a' to
the intended (Dress seed peels). 

Olaf



More information about the Haskell-Cafe mailing list