Ah, that worked perfectly! Thanks! On Sep 16, 2010, at 11:45 AM, Simon Peyton-Jones wrote:
> For reasons explained in “Let should not be generalised” GHC isn’t going to > generalise local let-bindings, at least not when you switch on GADTs , which > you have. > > So unBM is monomorphic, hence the error. > > Give it a type signature, or make it top-level. Either works fine. > > Simon > > From: [email protected] [mailto:[email protected]] On > Behalf Of David Peixotto > Sent: 16 September 2010 17:38 > To: [email protected] > Subject: New type error when compiling with GHC head > > I'm now getting a type error when compiling with GHC HEAD that I wasn't > getting before (also GHC 6.10 and GHC 6.12 work fine). The code is part of a > larger program that I did not write and the type error is confusing to me. I > cut it down to the minimal I could, so hopefully it will be useful. Can > someone comment if this is a bug, or the program needs to be changed? > > Code:(Backtrack.hs) > {-# OPTIONS_GHC -fglasgow-exts #-} > module Backtrack where > import Control.Monad > > -- Combining endomorphisms and continuations > -- a la Ralf Hinze > > -- BacktrackM = state monad transformer over the backtracking monad > newtype BacktrackM s a = BM (forall b . (a -> s -> b -> b) -> s -> b -> b) > > instance Monad (BacktrackM s) where > return a = BM (\c s b -> c a s b) > BM m >>= k = BM (\c s b -> m (\a s b -> unBM (k a) c s b) s b) > where unBM (BM m) = m > fail _ = mzero > > instance MonadPlus (BacktrackM s) where > mzero = BM (\c s b -> b) > (BM f) `mplus` (BM g) = BM (\c s b -> g c s $! f c s b) > > Error: > Backtrack.hs:13:18: > Couldn't match type `b' with `b2' > because this skolem type variable would escape: `b2' > This skolem is bound by > the polymorphic type `forall b. (a -> s -> b -> b) -> s -> b -> b' > The following variables have types that mention b > unBM :: BacktrackM s b1 -> (b1 -> s -> b -> b) -> s -> b -> b > (bound at Backtrack.hs:14:13) > In the first argument of `BM', namely > `(\ c s b -> m (\ a s b -> unBM (k a) c s b) s b)' > In the expression: > BM (\ c s b -> m (\ a s b -> unBM (k a) c s b) s b) > In an equation for `>>=': > (BM m) >>= k > = BM (\ c s b -> m (\ a s b -> unBM (k a) c s b) s b) > where > unBM (BM m) = m > > -David >
_______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
