[Haskell] Re: GHC Error question

Norman Ramsey nr at eecs.harvard.edu
Thu Dec 7 00:06:53 EST 2006


 > Norman Ramsey wrote:
 > 
 > >   compile1 :: (Builder b box) => t -> Name -> Ir.ANF -> b t
 > >   compile1 f x body = do env <- compile body empty
 > >                          wire (Arg W) (env x)
 > >                          return f
 > >   class (Monad b) => Builder b box where
 > >     wire            :: Source box -> Sink box -> b ()
 > > This program is rejected by GHC...
 > 
 > He continued, [paraphrase] however, compile1 is accepted if the signature is
 > removed. Furthermore, the inferred signature seems identical to the
 > one given above.
 > 
 > That is not a bug...
 >
 > What to do? If applicable, add a functional dependency ...
 > 
 > Or, one may use the local type variable to the same end
 > 
 > >   compile1 :: forall b t box. (Builder b box) => t -> Name -> Ir.ANF -> b
 > >   t compile1 f x body = do env <- compile body empty
 > >                          wire ((Arg W)::Source box) (env x)
 > >                          return f
 > 
 > the explicit `forall' binder is required.

This suggestion, I like.  I have always hated that ML and Haskell
leave the foralls implicit.  Bad design.

To be sure I understand: the reason the explicit forall is required is
to bring 'box' into scope so it can be used in the type constraint on
(Arg W)?


Norman


More information about the Haskell mailing list