miso
Copyright(C) 2016-2026 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Miso.String.QQ

Description

Overview

Miso.String.QQ provides the misoString quasi-quoter, which lets you write multiline MisoString literals with preserved whitespace and indentation directly in Haskell source.

Enable the extension and import the quoter:

{-# LANGUAGE QuasiQuotes #-}
import Miso.String.QQ (misoString)

Quick start

{-# LANGUAGE QuasiQuotes #-}
import Miso.String.QQ
import Miso.String (MisoString)

-- Multiline literal — newlines and indentation are preserved as-is
myCSS :: MisoString
myCSS = [misoString|
  body {
    margin: 0;
    font-family: sans-serif;
  }
|]

-- Useful for injecting inline <style> or <script> content:
view :: Model -> View Model Action
view _ =
  div_ []
    [ style_ [] [ text myCSS ] ]

How it works

The quasi-quoter is expression-only (quoteExp). At compile time it splices toMisoString <the-literal-string>, so the result is identical to writing ms "…" but without needing to escape newlines or quotes inside the brackets.

quotePat, quoteType, and quoteDec are not implemented and will produce a compile error if attempted.

See also

Synopsis

Documentation

misoString :: QuasiQuoter Source #

QuasiQuoter for specifying multiline MisoString

{-# LANGUAGE QuasiQuotes #-}

test :: MisoString
test = [misoString| foo
  bar
    baz
|]