Skip to content

gtollini/io-embed

Repository files navigation

io-embed

This library allows you to embed the result of an IO computation at compile time - as long as said computation is internally typed as: Char, String, Integer, Rational, or ByteString.

Installation

This package is available through both Cabal and Stackage.

Usage

Here's how you could embed the contents of a file using IOEmbed:

{-# LANGUAGE TemplateHaskell #-}

fileContent = $(embedIO $ readFile "./README.md")

Alternativelly, you could use IOEmbedLit by hand-crafting a Lit. This is useful if you want to embed something other than the types listed above.

{-# LANGUAGE TemplateHaskell #-}

fileContentL = $(embedIOLit $ StringL <$> readFile "./README.md")

Releases

No releases published

Packages

No packages published