Giter VIP home page Giter VIP logo

interpol's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

bitonic

interpol's Issues

Preprocessor imports Text.Interpol unqualified

The preprocessor should import qualified Text.Interpol to avoid conflicts with other (^-^) operators. The following code results in "ambiguous occurrence" errors:

{-# OPTIONS_GHC -F -pgmF interpol #-}

module Bug where

(^-^) :: String -> Int -> String
(^-^) s n = s ++ "hello {n}"

As an aside, I think you should just add the import every time. The strstr "^-^" (prettyPrint m) check in the preprocessor is expensive and isn't even accurate (it matches strings containing "^-^" in addition to uses of the operator). To avoid unused import warnings, you can use the form import qualified Text.Interpol ().

Transformed source has incorrect LINE pragmas

After interpol preprocessing, there's a single LINE 1 pragma at the top of the file, but no others, even though comments are stripped and whitespace is changed. This leads to GHC's error messages pointing at wrong lines. Consider for example:

-- Hello!

{-# OPTIONS_GHC -F -pgmF interpol #-}

-- Hey there!

module Bug where


-- Greetings!


foo :: Int
foo = "wrong type"

-- Bye!

After ghc -E, we're left with:

{-# LINE 1 "asdf.hs" #-}
{-# OPTIONS_GHC -F -pgmF interpol  #-}
module Bug where

foo :: Int
foo = "wrong type"

And the error message points to asdf.hs:5:7 instead of asdf.hs:14:7. If foo here were to contain a string interpolation, it'd point to line 6 instead of 5, as the import of Text.Interpol would be added.

The Test/NoWarn.hs file in the repository is another example of a file that would suffer from this, if it were to contain any type errors. (For example, try removing putStrLn from the definition of foo there.)

I'm not sure what can be done about this as I'm not at all familiar with haskell-src-exts. In my mind, the simplest solution would be to not modify the original source in any way except to perform the string interpolation (duh), add the import, and immediately after the import add a LINE pragma for the appropriate line number. If that's not an option, you need a LINE pragma after every removed comment and blank line...

Executing `make test` twice fails

After the first make test, when doing it again:

 % make test
cabal build
Building interpol-0.2.3...
Preprocessing library interpol-0.2.3...
Registering interpol-0.2.3...
Preprocessing executable 'interpol' for interpol-0.2.3...
rm -f Test/*.{hi,o}
rm -f Test/Simple
rm -f Test/One
rm -f Test/String
rm -f Test/NoImport
rm -f Test/Standalone
rm -f Test/Pure
rm -f Test/PureString
rm -f Test/NoWarn
rm -f Test/JustShow
rm -f Test/OperatorConflicts
cabal test
cabal: No test suites enabled. Did you remember to configure with
'--enable-tests'?
make: *** [test] Error 1

Probably some Makefile business. @scvalex can you have a look?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.