stdio-0.2.0.0: A simple and high performance IO toolkit for Haskell

Copyright(c) Dong Han 2017-2018
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Std.Data.PrimArray.QQ

Contents

Description

This module provides functions for writing PrimArray related literals QuasiQuote.

Synopsis

PrimArray literal quoters

quoter helpers

asciiLiteral Source #

Arguments

:: (ExpQ -> ExpQ -> ExpQ)

Construction function which receive a byte length Int and a Addr# LitE expression.

-> String

Quoter input

-> ExpQ

Final Quoter

Construct data with ASCII encoded literals.

Example usage:

arrASCII :: QuasiQuoter
arrASCII = QuasiQuoter
    (asciiLiteral $  len addr -> [| word8ArrayFromAddr $(len) $(addr) |])
    ...

word8ArrayFromAddr :: Int -> Addr# -> PrimArray Word8
{--}
word8ArrayFromAddr l addr# = runST $ do
    mba <- newPrimArray (I# l)
    copyPtrToMutablePrimArray mba 0 (Ptr addr#) l
    unsafeFreezePrimArray mba

utf8Literal :: (ExpQ -> ExpQ -> ExpQ) -> String -> ExpQ Source #

Construct data with UTF-8 encoded literals.

Smiliar to asciIILiteral, the