<div dir="ltr"><div>You can't write that lens by hand, so it isn't surprising that the template haskell can't generate it either. =)<br></div><div><br></div><div>ImpredicativeTypes don't work all that well.</div>
<div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Sep 8, 2013 at 9:49 AM, Artyom Kazak <span dir="ltr"><<a href="mailto:yom@artyom.me" target="_blank">yom@artyom.me</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here’s a small example, which, when compiled, gives an error. Why?<br>
<br>
{-# LANGUAGE FlexibleInstances, ImpredicativeTypes,<br>
TemplateHaskell #-}<br>
<br>
import Control.Lens<br>
<br>
class Item a where<br>
name :: a -> String<br>
<br>
instance Item (String, Int) where<br>
name = fst<br>
<br>
type ItemFilter = Item a => a -> Bool<br>
<br>
data ItemBox = ItemBox { _itemFilter :: ItemFilter }<br>
makeLenses ''ItemBox<br>
<br>
The error is<br>
<br>
Couldn't match type `a0 -> Bool'<br>
with `forall a. Item a => a -> Bool'<br>
Expected type: ItemFilter<br>
Actual type: a0 -> Bool<br>
In the expression: b_aaZE<br>
In the first argument of `iso', namely<br>
`\ (ItemBox b_aaZE) -> b_aaZE'<br>
In the expression: iso (\ (ItemBox b_aaZE) -> b_aaZE) ItemBox<br>
<br>
I’m using GHC 7.6.2, if it’s important.<br>
<br>
______________________________<u></u>_________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>