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

[ bsd3, data, library, template-haskell ] [ Propose Tags ] [ Report a vulnerability ]

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


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

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
Revised Revision 4 made by gtollini at 2024-10-08T19:58:10Z
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-08T04:10:47Z
Distributions Stackage:0.1.0.1
Downloads 52 total (17 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-22 [all 6 reports]

Readme for io-embed-0.1.0.0

[back to package description]

IOEmbed

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