On Fri, Jun 08, 2007 at 07:49:20PM +0200, Tomasz Zielonka wrote:
> On Fri, Jun 08, 2007 at 05:23:23PM +0200, Phlex wrote:
> > But i don't seem to find a way to get out of this DbIndex type to 
> > actually work on the enclosed index.
> > 
> > for instance, this doesn't work:
> > liftDbIndex (DbIndex index) fun = DbIndex (fun index)
> 
> The compiler probably can't infer higher-ranker types, so you have to
> write you type signature explicitly. Try:
> 
>     liftDbIndex :: Index_ i2 a2 k2 =>
>                    (forall a1 k1 i1. Index_ i1 a1 k1 => i1 -> i2) -> DbIndex 
> -> DbIndex

Now I think that this type signature will be too restrictive. Ideally, i2, a2 
and
k2 would be existentially quantified, like

    liftDbIndex :: (forall a1 k1 i1. Index_ i1 a1 k1 => i1 -> (exists. Index_ 
i2 a2 k2 => i2)) ->
                   DbIndex -> DbIndex

AFAIK such type isn't supported by any Haskell compiler, so we have to
use the existential quantification from DbIndex:

    liftDbIndex :: (forall a1 k1 i1. Index_ i1 a1 k1 => i1 -> DbIndex) -> 
DbIndex -> DbIndex
    liftDbIndex f (DbIndex i) = f i

Best regards
Tomek
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to