Search code examples
haskellghcghci

Is it possible to make prompt-function work with -XNoImplicitPrelude?


I have a project that uses a custom Prelude, however it seems to conflict with the prompt function I have in ~/.ghci. Simple example:

$ ghci -XNoImplicitPrelude
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/refold/etc/ghci
> :set prompt-function \ms _ -> ms

<interactive>:1:19: error:
    Not in scope: type constructor or class ‘String’

<interactive>:1:30: error:
    Not in scope: type constructor or class ‘Int’

<interactive>:1:37: error:
    Not in scope: type constructor or class ‘IO’

<interactive>:1:40: error:
    Not in scope: type constructor or class ‘String’

Is it possible to make both -XNoImplicitPrelude and :set prompt-function work together?


Solution

  • Put String, Int, IO, and whatever is necessary, back in scope. If Prelude is not available (because of using base-noprelude), these types can be found in their own modules:

    > import Data.String (String)
    > import Data.Int (Int)
    > import System.IO (IO)
    > import Text.Show (show)
    > import Control.Applicative (pure)
    > :set prompt-function \ms n -> pure (show (ms, n))  -- [String] -> Int -> IO String