Thursday, October 6, 2011

HaTeX 3 - First release

Wow! I finally do the first release to Hackage of HaTeX 3:

http://hackage.haskell.org/package/HaTeX-3.0.0

You can try it with the next example!


{-# LANGUAGE OverloadedStrings #-}

import Text.LaTeX.Base.Monad

main :: IO ()
main = do
 l <- execLaTeXT example
 renderFile "Example.tex" l


example :: Monad m => LaTeXT_ m
example = do
 documentclass [] article

 document exampleBody


exampleBody :: Monad m => LaTeXT_ m
exampleBody = do
 "This is an example of how "
 hatex3
 " works, printing a table of "
 "the thirteen first elements of the "
 "Fibonacci sequence."
 bigskip
 center $ underline $ textbf "Fibonacci table"
 center $ tabular Nothing [RightColumn,VerticalLine,LeftColumn] $ do
   textbf "Fibonacci number" & textbf "Value"

   lnbk
   hline
   foldr (\n l -> do fromString (show n) & fromString (show $ fib n)
                     lnbk
                     l ) (return ()) [0..12]


fibs :: [Int]
fibs = 1 : 1 : zipWith (+) fibs (tail fibs)


fib :: Int -> Int
fib = (fibs!!)

This example builds a table with the thirteen first elements of the Fibonacci sequence.

I'm writing a manual for the library, but it will take me some time (and time is sometimes hard to find).

Until the next time!
Daniel Díaz.

No comments: