tmhedberg / here Goto Github PK
View Code? Open in Web Editor NEWHaskell here docs & interpolated strings via quasiquotation
License: BSD 3-Clause "New" or "Revised" License
Haskell here docs & interpolated strings via quasiquotation
License: BSD 3-Clause "New" or "Revised" License
It's often convenient to use a nice QuasiQuoter like this all over the place. Unfortunately, different call sites need different kinds of strings. It would be extremely convenient if this package offered variants (either by name, or by a separate module) that produce polymorphic strings IsString a
.
Running cabal install here
fails with (cabal log):
Configuring here-1.2.5...
Building here-1.2.5...
Preprocessing library here-1.2.5...
[1 of 4] Compiling Data.String.Here.Internal ( src/Data/String/Here/Internal.hs, dist/build/Data/String/Here/Internal.o )
[2 of 4] Compiling Data.String.Here.Uninterpolated ( src/Data/String/Here/Uninterpolated.hs, dist/build/Data/String/Here/Uninterpolated.o )
[3 of 4] Compiling Data.String.Here.Interpolated ( src/Data/String/Here/Interpolated.hs, dist/build/Data/String/Here/Interpolated.o )
src/Data/String/Here/Interpolated.hs:132:13:
Not in scope: data constructor ‘State’
Perhaps you meant ‘StateT’ (imported from Control.Monad.State)
src/Data/String/Here/Interpolated.hs:132:13:
You cannot use `..' in a record pattern
src/Data/String/Here/Interpolated.hs:132:30:
‘statePos’ is not a (visible) constructor field name
src/Data/String/Here/Interpolated.hs:132:57:
Not in scope: ‘statePos’```
The version on Hackage doesn't allow for GHC 7.8. As more and more packages transition to 7.8, it'd be great if here
allowed that so things that depend on it can also transition.
I am seeing all blank lines being stripped, by here
and hereLit
. So eg paragraphs of text separated by blank lines are run together in the output. Is this expected ?
The template
quasiquoter should use TemplateHaskell's addDependentFile
. That way, when the files being quoted are changed, re-running cabal build
(or a different compilation command) will actually recompile the module, instead of ignoring the fact that the files changed.
Does the quasiquoter produce String
, IsString a
, or something else?
This is important since the newest Stackage snapshot uses it. Sadly haskell-src-meta doesn't support it, so this might not be possible just yet.
Reported by Neil Brown via email:
Just to let you know, the here library (version 1.2.2) hangs at
compile-time if I try to use a variable that has a single apostrophe
in its name. Minimal example (GHC 7.4.1):{-# LANGUAGE QuasiQuotes #-}
import Data.String.Here.Interpolated (i)
main :: IO()
main = let x' = "" in putStrLn [i|Problem: ${x'}|]In my real example, I'll rename my variable, but I thought you might
want to know. I'm guessing this is to do with parsing: I could
perhaps live with a parsing error, but a compile-time hang is a bit
annoying to track down if you don't immediately know the problem.
λ> :set -XQuasiQuotes
λ> import Data.String.Here
λ> putStrLn [i|${"one"} $ ${"two"}|]
one $ ${"two"}
Could there be a new version pushed to Hackage that allows base==4.8.*
and GHC 7.10?
Hi!
I'm trying to install here with cabal, but I get this error: https://gist.github.com/alexeiras/09791c27d7b6786264f4
I'm using ghc 7.8.3 and cabal-install 1.20.0.3 with Cabal lib 1.20.0.2 on Mac OS X 10.9.4
¿Any hint?
> text = "Test" :: Text
> [i|${text}|]
"\"text\""
Is there a reason that newer mtl (such as 2.2.*
) is forbidden?
I would like to use your library for interpolating in other contexts. A large majority of your code could be reused. Would you be open to accepting a PR that exposed your parsers with some additional abstraction or a PR that used an upstream library (derived from your parsers) to do the parsing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.