Skip to content

Instantly share code, notes, and snippets.

@rhz rhz/gist:2219713
Created Mar 27, 2012

Embed
What would you like to do?
module Main where
import System.Process
import System.Environment (getArgs)
import Data.List (intercalate)
data Gender = Male
| Female
data Var = FirstValue
| SecondValue
| ThirdValue
data Person = Person { name :: String
, surname :: String
, gender :: Gender
, var :: Var
}
header = "Oficina Nacional de Ejemplos"
greeting = "Estimado"
intro = "A partir de su solicitud, los resultados de su prueba de DNA le son entregados a continuación. Antes de continuar debemos reacalcar los siguientes puntos de importancia: \n\n\
\\\begin{enumerate}\n\
\ \\item Esta prueba de DNA fue realizada en el contexto de un proyecto de investigación científica, sin utilizar las reglas y métodos que demandan las pruebas para diagnóstico clínico. Por lo tanto \\underline{usted no debe interpretar estos resultados como un diagnóstico}\n\
\\\end{enumerate}\n"
closing = "Atentamente,"
signature = "Nicolás Montalva \\\\ Departamento de Antropología \\\\ University College London"
genderPrefix Male = "Sr."
genderPrefix Female = "Sra."
body FirstValue = "Texto 1"
body SecondValue = "Texto 2"
body ThirdValue = "Texto 3"
sep = "\n\n"
contents person =
intercalate sep [ "\\documentclass[]{letter}"
, "\\usepackage[utf8]{inputenc}"
, "\\usepackage[spanish]{babel}"
, "\\begin{document}"
, "\\begin{letter}{" ++ header ++ "}"
, "\\opening{" ++ unwords [greeting, genderPrefix (gender person), name person, surname person ++ ","] ++ "}"
, intro
, body (var person)
, closing
, signature
, "\\end{letter}"
, "\\end{document}"
]
makePerson nameStr surnameStr genderStr varStr =
Person{ name = nameStr, surname = surnameStr, gender = genderValue, var = varValue }
where genderValue | genderStr == "M" = Male
| genderStr == "F" = Female
varValue | varStr == "1" = FirstValue
| varStr == "2" = SecondValue
| varStr == "3" = ThirdValue
main = do nameStr:surnameStr:genderStr:varStr:_ <- getArgs
let person = makePerson nameStr surnameStr genderStr varStr
writeFile "carta.tex" (contents person)
system ("pdflatex carta.tex")
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.