user2340939
user2340939

Reputation: 1991

Not in scope in Haskell

When I try to compile the code from http://michaeldadams.org/papers/scrap_your_zippers/ScrapYourZippers.hs I get:

ScrapYourZipper.hs:249:15: Not in scope: type variable ‘hole’   
ScrapYourZipper.hs:251:27: Not in scope: type variable ‘root’
ScrapYourZipper.hs:252:20: Not in scope: type variable ‘hole’ 
ScrapYourZipper.hs:252:25: Not in scope: type variable ‘root’

The part of code where this happend:

245    data Context hole root where
246    CtxtNull :: Context a a
247    CtxtCons ::
248      forall rights parent. (Data parent) =>
249        Left (hole -> rights)
250        -> Right rights parent
251        -> Context parent root
252        -> Context hole root

Any ideas/pointers to whats wrong?

PS: Sorry for poor naming of the post, coulnd't think of anything meaningfully.

Upvotes: 1

Views: 1433

Answers (2)

kosmikus
kosmikus

Reputation: 19657

Line 248 should be

forall rights parent root hole. (Data parent) =>

It's possible that GHC used to be more permissive here in older versions ...

Upvotes: 0

ErikR
ErikR

Reputation: 52057

I replaced that data declaration with:

data Context hole root where
    CtxtNull :: Context a a
    CtxtCons :: (Data parent) => Left (hole -> rights) -> Right rights parent -> Context parent root -> Context hole root

(i.e. just remove the forall clause) and it compiled.

Upvotes: 4

Related Questions