Git Product home page Git Product logo

here's Introduction

here

here is a package that adds support for multi-line string literals (a.k.a. "here docs") and string interpolation to Haskell via GHC's QuasiQuotes extension.

The quoted expressions behave like string literals in the source code; that is, they produce values of type String, or, with the OverloadedStrings language extension enabled, values of type IsString a => a.

The package includes six quasiquoters:

  • here: Strips leading and trailing whitespace. This allows you to add a line break after the opening quote bracket, which looks nicer.
  • hereLit: Quotes the here doc literally, with no whitespace stripping
  • hereFile: Quotes a file's contents as a here doc
  • i: Like hereLit, but with the ability to interpolate the values of antiquoted Haskell expressions (bracketed by ${ and })
  • iTrim: Like i, but trimming leading and trailing whitespace as with here
  • template: Applies string interpolation to a file, as a simple template engine

Example

{-# LANGUAGE QuasiQuotes #-}

import Data.Char
import Data.String.Here

main = do let foo = "foo"
          putStrLn [i|"foo", when capitalized, is ${map toUpper foo}!|]
          putStrLn [here|
Hello world,

I am a multiline here doc!
|]

Output

"foo", when capitalized, is FOO!
Hello world,

I am a multiline here doc!

here's People

Contributors

tmhedberg avatar nwtgck avatar cocreature avatar bgamari avatar borsboom avatar snoyberg avatar nkpart avatar np avatar peti avatar ncaq avatar

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.