2014-01-09 20:37:31 -05:00
..
2014-01-06 15:25:30 -05:00
2014-01-06 15:25:30 -05:00
2014-01-06 15:25:30 -05:00

IHaskell-Magic

Instances of IHaskellDisplay for Text and ByteString, where the actual image or text format is determined using libmagic, which classifies files according to their contents. It is the same as the shell command file(1). Depending on your OS, you will have to install the c-library first. On a debian-like OS:

apt-get install libmagic-dev
cd ihaskell-magic
cabal install

The instances provided allow displaying images and text with markup using just one line:

import qualified Data.ByteString as B
import qualified Data.Text.IO as T
B.readFile "foo.png"
B.readFile "foo.svg"
B.readFile "foo.jpg" -- currently broken (Jan6,2014)
T.readFile "foo.tex" -- doesn't work that well for literal strings,
                     -- since you pretty much need a \documentclass[]{} to get
                     -- the file recognized, at which point I'm not sure it renders
T.readFile "foo.html"

While you can use B.readFile "foo.tex", that involves more assumptions regarding encodings.