ndmitchell / debug

Haskell library for debugging
BSD 3-Clause "New" or "Revised" License
122 stars 7 forks source link

Parse error when using the pragma #35

Closed marklnichols closed 6 years ago

marklnichols commented 6 years ago

I put this at the top of small test file: {-# OPTIONS -F -pgmF debug-pp #-}

I did a build and launched GHCi. The new module wasn't pre-loaded by GHCI, but when I tried to load the source file via -l I got:

parse error on input `import'

pepeiborra commented 6 years ago

Thanks for the report but I am struggling to reproduce. Please the source for your small test file and a more detailed set of steps

marklnichols commented 6 years ago

Ok, here is the file, Temp.hs, in the src directory of the debug project:

{-# OPTIONS -F -pgmF debug-pp #-}

module Temp where

f :: Int -> Int
f = (2*)

oneX :: [Int] -> [Int] -> [Int]
oneX ys zs =
    case ys of
        x : xs -> f x : xs ++ zs
        [] -> zs

manyXs :: [Int] -> [Int] -> [Int]
manyXs x y =
    case x of
        x : xs -> f x : xs ++ y
        [] -> y

lg :: (Integral a) => a -> a -> Double
lg x y =
    let least = lcm x y
    in fromIntegral least ^^ gcd x y

l1, l2 :: [Int]
l1 = [1, 2, 3, 4, 5]
l2 = [6, 7, 8, 9, 10]

I'm using Stack, so stack build (no errors) and then stack ghci (no errors).

Then, inside ghci:

:l src\Temp.hs

gives:

[1 of 1] Compiling Temp             ( src\Temp.hs, interpreted )
C:\Users\Mark\AppData\Local\Temp\ghc17100_0\ghc_15.hspp:36:1: error: parse error on input `import'
Failed, modules loaded: none.
pepeiborra commented 6 years ago

Your example has no import Foo lines, which throws off the preprocessor. This is a bug, thanks for the report !