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

[ bsd3, data, library, template-haskell ] [ Propose Tags ]

Please see the README on GitHub at https://github.com/gtollini/io-embed#readme


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), bytestring (>=0.11.5.2 && <0.13), hspec (>=2.11.7 && <2.12), template-haskell (>=2.20.0.0 && <2.23.0.0) [details]
License BSD-3-Clause
Copyright 2024 Gabriel Tollini
Author Gabriel Tollini
Maintainer gabrieltollini@hotmail.com
Category bsd3, template-haskell, data, library
Home page https://github.com/gtollini/io-embed#readme
Bug tracker https://github.com/gtollini/io-embed/issues
Source repo head: git clone https://github.com/gtollini/io-embed
Uploaded by gtollini at 2024-10-10T22:47:06Z
Distributions
Downloads 30 total (30 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-10-10 [all 1 reports]

Readme for io-embed-0.1.0.1

[back to package description]

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