Marc
Marc

Reputation: 4477

Haskell: "Not in scope: '>>'" with no implicit prelude

Compiling the following Haskell program with GHC 6.12.1 yields an error:

{-# LANGUAGE NoImplicitPrelude #-}

module Example where

import Prelude(Integer, fromInteger, (==))

f :: Integer -> Integer
f n
    | n == 0 = 0

Namely:

example.hs:9:6: Not in scope: `>>'

The error goes away when I change the import statement to:

import Prelude(Integer, fromInteger, (==), (>>))

This makes sense. What I don't understand, however, why there is an error in the first place. My program doesn't seem to make use of any Monad, while >> is one of the Monad operators.

Upvotes: 13

Views: 1696

Answers (3)

Marat Salikhov
Marat Salikhov

Reputation: 6627

I don't know the root cause of this problem, but if you compile your code with -ddump-rn-trace option on, you can see that the compiler for some reason puts (>>) into a list of definitions used, something like that:

    finish Dus [(Nothing, [(314, Integer)]),
            (Just [(rdd, f)], [(01D, >>), (01E, fromInteger), (01L, ==)]),
            (Nothing, [])]

Most certainly it is a bug in GHC 6.12.1

Upvotes: 9

augustss
augustss

Reputation: 23014

This is a bug in ghc. You should report it.

Upvotes: 2

Ingo
Ingo

Reputation: 36339

I can imagine the compiler checks to see if >> is present (which it needs for compilation of do-blocks), no matter if do occurs in your code. (But then, it should also complain about >>=)

Upvotes: 1

Related Questions