MyNixOS website logo
Description

Here document without variable expansion like PHP Nowdoc.

Please see the README on GitHub at https://github.com/YoshikuniJujo/nowdoc#readme

nowdoc

Package nowdoc contain 3 QuasiQuotes.

  • nowdoc: Simplest here document with only two transformation.
  • txtfile: It incerts text file contents as string.
  • binfile: It incerts binary file contents as string.

QuasiQuoter nowdoc

Simplest here document. Only two transformation.

  • remove head newline if exist
  • remove one space from '|', space, space, ..., ']'

short examples

hello = [nowdoc|
abc
def
ghi
|]

is

hello = "abc\ndef\nghi\n"

,

hello = [nowdoc|hello|]

is

hello = "hello"

and

hello = [nowdoc|
hello | ]
world |  ]
! |   ]
|]

is

hello = "hello |]\nworld| ]\n! |  ]"

run perl

{-# LANGUAGE QuasiQuotes #-}

import System.Process
import Text.Nowdoc

main :: IO ()
main = () <$ rawSystem "perl" ["-e", [nowdoc|
use strict;
use warnings;

my $hello = "Hello, world!\n";
print $hello;
|]]

ASCII art

{-# LANGUAGE QuasiQuotes #-}

import Text.Nowdoc

main :: IO ()
main = putStr [nowdoc|
            ______             
       .d$$$******$$$$c.       
    .d$P"            "$$c      
   $$$$$.           .$$$*$.    
 .$$ 4$L*$$.     .$$Pd$  '$b   
 $F   *$. "$$e.e$$" 4$F   ^$b  
d$     $$   z$$$e   $$     '$. 
$P     `$L$$P` `"$$d$"      $$ 
$$     e$$F       4$$b.     $$ 
$b  .$$" $$      .$$ "4$b.  $$ 
$$e$P"    $b     d$`    "$$c$F 
'$P$$$$$$$$$$$$$$$$$$$$$$$$$$  
 "$c.      4$.  $$       .$$   
  ^$$.      $$ d$"      d$P    
    "$$c.   `$b$F    .d$P"     
      `4$$$c.$$$..e$$P"        
          `^^^^^^^`
|]

QuasiQuoter txtfile

It incerts file contents as string without transformation. It read file as text file (with default encoding on your system).

main :: IO ()
main = putStr [txtfile|foo.txt|]

QuasiQuoter binfile

It incerts file contents as string without transformation. It read file as binary file.

main :: IO ()
main = print [binfile|foo.dat|]
Metadata

Version

0.1.1.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows