io-embed

Use Template Haskell to embed the result of an IO computation.

https://github.com/gtollini/io-embed#readme

Stackage Nightly 2024-11-25:0.1.0.1
Latest on Hackage:0.1.0.1

See all snapshots io-embed appears in

BSD-3-Clause licensed by Gabriel Tollini
Maintained by [email protected]
This version can be pinned in stack with:io-embed-0.1.0.1@sha256:83f7bc99a00be7b11cffab83180d1444fc4bb93b9fe108c3e3ed131329c058f2,1999

Module documentation for 0.1.0.1

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")

Changes

Changelog for IOEmbed

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to the Haskell Package Versioning Policy.

Unreleased

0.1.0.0 - YYYY-MM-DD