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