packages feed

hatex-guide 1.3.1.1 → 1.3.1.2

raw patch · 11 files changed

+117/−116 lines, 11 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Text/LaTeX/Guide/Auto.hs view
@@ -7,4 +7,4 @@  -- | The version of the guide. Based on the version of the package. guideVersion :: Version-guideVersion = Version [1,3,1,1] []+guideVersion = Version [1,3,1,2] []
Text/LaTeX/Guide/Backend/HTML.hs view
@@ -17,7 +17,6 @@ -- import Data.Monoid import Control.Monad.Trans.State-import Control.Applicative ((<$>)) import Data.List (intersperse) import Data.Version (showVersion) -- Time
Text/LaTeX/Guide/Backend/Wiki.hs view
@@ -12,7 +12,7 @@ import Data.Text.IO import Data.Functor import Data.Function-import Prelude (Eq (..), Num (..),IO,Monad (..), Int, uncurry, Show (..))+import Prelude (Eq (..), Num (..),IO,Monad (..), Int, Show (..)) import Data.String (IsString (..))  tag :: Text -> Text -> Text
Text/LaTeX/Guide/Info.hs view
@@ -9,7 +9,6 @@  import Text.LaTeX.Guide.Syntax import System.FilePath-import Data.Monoid import System.Directory (getAppUserDataDirectory)  -- | Ordered list of sections.@@ -26,7 +25,7 @@ -- | List of contributors. Please, insert your name here if you have contributed --   in some way to the guide. contributors :: [String]-contributors = [ ]+contributors = [ "GetContented" ]  -- | Available backends. data Backend = LaTeX | Wiki | HTML
hatex-guide.cabal view
@@ -1,5 +1,5 @@ Name: hatex-guide-Version: 1.3.1.1+Version: 1.3.1.2 Author: Daniel Díaz Build-type: Custom Category: LaTeX
src/basics.htxg view
@@ -6,13 +6,14 @@  If you are already familiar with the \{Monoid\} class, jump to the next point. The \{Monoid\} class is something that you must get used to in Haskell. But don't worry, it is quite simple-(in spite of the similarity in the name with the \{Monad\} class).-A /monoid/ in Mathematics is an algebraic structure consisting of a set of objects with-an operation between them, being this operation /associative/ and with a /neutral element/.+(despite having a similar name to the \{Monad\} class).+A /monoid/ in Mathematics is an algebraic structure consisting of a set of objects, +an /associative/ operation and a /neutral element/. Phew! But what is the meaning of this? By /associative/ we mean that, if you have three elements-$a$, $b$ and $c$, then $a*(b*c) = (a*b)*c$. A /neutral element/ is the one that does not worth to operate with,-because it does nothing! To say, $e$ is a /neutral element/ if $e*a=a*e=a$, given any object $a$.-As an example, you may take the /real numbers/ as objects and the ordinary multiplication as operation.+$a$, $b$ and $c$, then $a*(b*c) = (a*b)*c$. A /neutral element/ is one that does not change other values when operated with,+because it means nothing with respect to the operation! To say, $e$ is a /neutral element/ if $e*a=a*e=a$, given any object $a$.+As an example, you may take the /real numbers/ as objects and the ordinary multiplication as operation, in which case+the /neutral element/ would be the number one.  Now that you know the math basics behind the \{Monoid\} class, let's see its definition: @@ -24,8 +25,8 @@ \]  See that \{mappend\} corresponds to the monoid operation and \{mempty\} to its neutral element.-The names of the methods may seem insuitable, but they correspond to an example of monoid:-the lists with the appending \{(++)\} operation. Who is the neutral element here? The empty list:+The names of the methods may seem unsuitable, but they correspond to a particular case of monoid:+the lists with the appending \{(++)\} operation. What is the neutral element here? The empty list:  \[ xs ++ [] = [] ++ xs = xs@@ -36,7 +37,7 @@ ##LaTeX blocks##  Suppose we have a well-formed\f-With /well-formed/ we mean that all braces, environments, math expressions, ... are closed.+By /well-formed/ we mean all braces, environments, math expressions, ... are closed. \f piece of \latex code, call it $a$. Now, let \{LaTeX\} be a Haskell type in which each element represents a well-formed@@ -45,16 +46,16 @@ two \{LaTeX\} blocks? As both are well-formed, so is the result. Thus, two blocks appended form another block. This way, we can define an operation over the \{LaTeX\} blocks. If we consider that a totally empty code is a well-formed piece of \latex code, we can speak about the empty block.-And, as the reader may notice, these blocks with its appending form a monoid. Namely, \{LaTeX\}-can be done an instance of the \{Monoid\} class.+And, as the reader may notice, these blocks with the append operation form a monoid. Namely, \{LaTeX\}+is an instance of the \{Monoid\} class. -Of course, our mission using \hatex is to create a \{LaTeX\} block that fits our purpose. The-way to achieve this is to create a multitude of \{LaTeX\} blocks and, then, use the \{Monoid\} operation-to collapse them all in a single block.+Of course, our objective when using \hatex is to create a \{LaTeX\} block that fits our purpose. The+way to achieve this is to create a multitude of \{LaTeX\} blocks and use the \{Monoid\} operation+to collapse them into a single block.  ##Creating blocks## -We have now a universe of blocks forming a monoid. What we need now is a way to create these blocks.+We now have a universe of blocks that form a monoid. What we need is a way to create these blocks. As we said, a block is the representation of a well-formed piece of \latex code. Let \{a\} be the block of the \latex expression \{\delta{}\}\f Please, note that the \{LaTeX\} block is *not* the same that the \latex expression. The former@@ -64,7 +65,7 @@ this value will generate the desired block.  Other \latex expressions depend on a given argument. For example \{\linespread{x}\}, where \{x\} is-a number. How we deal with this? As you expect, with functions. We can create blocks that depend on+a number. How do we use these? As you would expect, with functions. We can create blocks that depend on values with functions that take these values as arguments, where these arguments can be blocks as well. For instance, we have the function \{linespread\} with type: @@ -72,19 +73,19 @@ linespread :: Float -> LaTeX \] -As you may know, a title in \latex can contain itself \latex code. So the type for the Haskell+As you may know, a title in \latex can itself contain \latex code. So the type for the Haskell function \{title\} is:  \[ title :: LaTeX -> LaTeX \] -And this is, essentialy, the way to work with \hatex: *to create blocks and combine them*.-Once you have your final block ready, you will be able to create its corresponding \latex code-(we will see how later). Note that for every block there is a \latex code, but not for every code-there is a block, because a malformed (in the sense of the negation of our well-formed concept) code-has *not* a block in correspondence.-This fact has a practical consequence: *we cannot create malformed \latex code*. /And that's a good deal!/+And this is essentialy the way we work with \hatex: *to create blocks and combine them*.+Once you have your final block ready, you will be able to create the \latex code that corresponds to it+(we will see how later). Note that there is \latex code for every block, but not every piece of \latex+has a block, because a malformed (in the sense of the negation of our well-formed concept) code+doe *not* have a corresponding block.+This fact has a practical consequence: *we cannot create malformed \latex code* using \hatex. /And that's a good thing!/  ###From strings### @@ -97,41 +98,41 @@ \]  Since there is a set of characters reserved	to create commands or another constructions,-\hatex takes care and avoids them replacing each reserved character with a command which-output looks like the original character. For example, the backslash \{\\} is replaced with+\hatex takes care to avoid using them, replacing each with a command whose+output looks like the originally intended character. For example, the backslash \{\\} is replaced with the \{\backslash{}\} command. -The function that avoids reserved characteres is exported with the name \{protectString\}.+The function that avoids reserved characters is exported with the name \{protectString\}. Also, there is a variant for \{Text\} values called \{protectText\}.  The use of the \{IsString\} class is because the /Overloaded Strings/ extension.-This one is similar to the /Overloaded Numbers/ Haskell feature, which translates the number+This is similar to the /Overloaded Numbers/ Haskell feature, which translates the number \{4\} to \{fromInteger 4\}. In a similar way, with \{OverloadedStrings\} enabled, the string \{"foo"\} is translated to \{fromString "foo"\}. If we now apply this to our blocks, the string \{"foo"\} will be automatically translated to a \{latex\} block with /foo/ as content.-Quite handy! We will assume the \{OverloadedStrings\} extension enabled from now.+Quite handy! We will assume that the \{OverloadedStrings\} extension is enabled from now on.  ###More blocks### -There is a lot of functions for create blocks. In fact, we can say that this is the main purpose-of the library. \latex has a lot of commands, in order to set font attributes, create tables,-insert graphics, include mathematical symbols, etc. So \hatex have a function for each command-defined in \latex (to tell the truth, only for a small subset). Please, go to the API documentation-to read about particular functions. Build it locally or find it in Hackage: <http://hackage.haskell.org/package/HaTeX>.+There are a lot of functions to create blocks. In fact, we can say this is the primary purpose+of the library. \latex has a lot of commands: they can set font attributes, create tables,+insert graphics, include mathematical symbols, etc. So \hatex has a function for each command+defined in \latex (to tell the truth, only for a small subset). Please go to the API documentation+to read about particular functions - you can either build it locally or find it on Hackage: +<http://hackage.haskell.org/package/HaTeX>. You will find the class constraint \{LaTeXC l\} in every entity. \{LaTeX\} is an instance of this-class, so you can assume that \{l\} is the \{LaTeX\} datatype without any problem. More about-this in section about the \{LaTeXC\} class.+class, so you can think of \{l\} as the \{LaTeX\} datatype without any problem. There is more about+this in the section about the \{LaTeXC\} class.  ##Putting blocks together## -Once you have the blocks, as we said before, you need to append them. The \{mappend\}-method of the \{Monoid\} class does this work. If \{a\} and \{b\} are two blocks,+Once you have your blocks, as we said before, you need to join them. The \{mappend\}+method of the \{Monoid\} class will do this. If \{a\} and \{b\} are two blocks, \{mappend a b\}, or \{a `mappend` b\}, or even \{a <> b\}\f From *GHC 7.4*, \{(<>)\} is defined as a synonym for \{mappend\}. For previous versions of GHC, \hatex exports the synonym.-\f, is the block with-\{a\} and \{b\} juxtaposed. For long lists of blocks, you can try it with \{mconcat\}-as follows:+\f, return the juxtaposition of \{a\} and \{b\}. +For lists of blocks, you can use \{mconcat\} instead as follows:  \[ mconcat [ "I can see a "  , textbf "rainbow"@@ -141,10 +142,10 @@ ##Rendering##  This is the last step in our \latex document creation. When we have our final-\latex block \{a\}, the function \{renderFile\} can output it into a file, in+\latex block \{a\}, the function \{renderFile\} can output it to a file, in the form of its correspondent \latex code. -Say we have the next definition:+Say we have this definition:  \[ short =@@ -154,7 +155,7 @@  <> document (maketitle <> "This is all.") \] -Then, after calling \{renderFile "short.tex" short\}, the following file appears+Then, after calling \{renderFile "short.tex" short\}, the following file will appear in the current working directory (line breaks added for easier visualization):  \[@@ -167,8 +168,8 @@ \end{document} \] -Finally, you may use commands like \{latex\} or \{pdflatex\} to compile the \latex-output to dvi or pdf.+Finally, you may use commands like \{latex\} or \{pdflatex\} in your command line environment+to compile the \latex output to dvi or pdf.  The function \{renderFile\} is not only for \{LaTeX\} values. Let's see its type: @@ -176,7 +177,7 @@ renderFile :: Render a => FilePath -> a -> IO () \] -The \{Render\} class that appears in the context is defined:+The \{Render\} class that appears in the context is defined as:  \[ class Render a where@@ -184,18 +185,19 @@ \]  So, it is the class of types that can be rendered to a \{Text\} value. The-type \{LaTeX\} is an instance, but other types, like \{Int\} or \{Float\}, so are too.+type \{LaTeX\} is an instance, but other types, like \{Int\} or \{Float\}, are too. These instances are useful for creating blocks from other values. With the function \{rendertex\}, any value in the \{Render\} class can be transformed to a block. First,-the value is converted to \{Text\}, and then to \{LaTeX\} the same way we did with strings.-But, *be careful!* Because \{rendertex\} does *not* escape reserved characters.+the value is converted to \{Text\}, and then to \{LaTeX\} in the same way as we did with strings.+But, *be careful* because \{rendertex\} does *not* escape reserved characters. -##Try yourself##+##Try it yourself## -As always, the best way to learn something well is to try it by yourself.-Since to see code examples can give you a great help, \hatex comes with several-examples where you can see by yourself how to get the work done.+As always, the best way to learn something well is to try it for yourself.+Since looking at code examples can help you greatly, \hatex comes with several+examples at [<https://github.com/Daniel-Diaz/HaTeX/tree/master/Examples>] so +you can see for yourself how to accomplish various tasks. -The API reference is also a good point to keep in mind. Descriptions of functions-make you know how exactly they works. And, when they are not present, function names-with type signatures may be very helpful and descriptive.+The API reference is also a good reference to keep in mind. Descriptions of functions+allow you to know exactly how they work. Even when these are not present, just the+function names and their type signatures can be very helpful and descriptive.
src/class.htxg view
@@ -5,12 +5,12 @@ function definitions\f This was the approach taken in \hatex 3 until the version 3.3, where the \{LaTeXC\} class was included. \f-or to have a typeclass which unifies both interfaces. Since duplicate definitions is a hard work-and can arise problems\f+or to have a typeclass which unifies both interfaces. Since having duplicate definitions is hard work+and can raise many problems\f In fact, we had a problem with \hatex-meta, the program that automatically generated the duplicated functions.-The problem was described in a blog post: <http://deltadiaz.blogspot.com.es/2012/04/hatex-trees-and-problems.html>.+The problem was described in the following blog post: <http://deltadiaz.blogspot.com.es/2012/04/hatex-trees-and-problems.html>. \f, we took the second alternative and defined the \{LaTeXC\} typeclass. Both \{LaTeX\} and \{LaTeXT m a\} are-instances of \{LaTeXC\} (the second one is a little tricky), so every function in \hatex is defined using the-typeclass. This way, we have both interfaces with a single import, without being worry about maintaining-duplicated code. The cost is to have class constraints in type signatures. But these constraints are only required-in the package. At the user level, you choose your interface and write type signatures in consequence.+instances of \{LaTeXC\} (the second one is a little tricky), so every function in \hatex is defined using this+typeclass. This way, we can have both interfaces with a single import, without being worried about maintaining+duplicated code. The cost for this is that we must have class constraints in our type signatures. However, these constraints are only+required in the package. At the user level, you choose your interface and write type signatures correspondingly.
src/epilogue.htxg view
@@ -2,16 +2,17 @@  ##Notes about this guide## -*This guide is not static*. It will certainly be changed with the time.-Any reader can participate as a writer since the guide is itself open source (and-written in Haskell!). The source repository can be reached at:-<https://github.com/Daniel-Diaz/hatex-guide>. Read more detailed instructions in the+*This guide is not static*. It will certainly be changed as time passes.+Any reader can also help participate in its writing, since the guide is itself open source (and+written in Haskell!). The source repository can be found at:+<https://github.com/Daniel-Diaz/hatex-guide>. You can read more detailed instructions in the README file. -If you think there is something unclear, something hard to understand, please, report it.+If you think something is unclear, or hard to understand, please do take the time to report it.+We really appreciate it.  ##Notes from the author## -I would like to end this guide saying thanks to all the people that has been interested-in \hatex somehow, especially to those who contributed to it with patches, opinions-or bug reports. *Thanks*.+I would like to end this guide by saying thanks to all the people that have been interested+in \hatex in any way, especially to those who contributed to it with patches, opinions+and\/or bug reports. *Thanks*.
src/monad.htxg view
@@ -1,7 +1,7 @@ #LaTeX blocks and the Writer monad#  ##The Writer Monad##-Fixed a monoid \{M\}, the \{M\}-writer monad is just all possible pairs of elements from \{M\}+For any given monoid, \{M\}, the \{M\}-writer monad is just all possible pairs of elements from \{M\} and elements from other types. Thus, the Haskell declaration is as follows\f Some authors write it using tuples, like this: \{data W m a = W (a,m)\}.\f: @@ -9,7 +9,7 @@ data W m a = W m a \] -Note that to get the monad we need to fix the type \{m\} (kind of monads is \{* -> *\}). To inject+Note that to get the monad we need to fix the type \{m\} (the kind of monads is \{* -> *\}). To inject an arbitrary value into the monad (the Haskell \{return\} function) we use the neutral element (\{mempty\}) of the monoid. @@ -18,7 +18,7 @@ inject a = W mempty a \] -Think that no other element of \{m\} is possible to think: it is the only element we know of it!+Think about the element of \{m\}: there is only one element that it could be! Like any other monad, \{W m\} is also a \{Functor\}. We just apply the function to the value.  \[@@ -36,7 +36,7 @@  In this function we use the other \{Monoid\} method to combine both values. It is important to note that in both monad operations \{inject\} and \{join\} we used \{mempty\} and \{mappend\}-respectively. In practice, this is because they act equal. Indeed, they are equal if we forget the+respectively. In practice, this is because they act similarly to each other. Indeed, they are equal if we forget the \{a\} value. Now, we are ready to define the \{Monad\} instance:  \[@@ -45,10 +45,10 @@  w >>= f = join (fmap f w) \] -There is nothing to say about this instance. It is and standard definition valid to any monad.+There is nothing to say about this instance. It is a standard definition, valid for any monad. -What we have done here is to hide in a monad a monoid with all its operations. We have created a-machine that operates monoid values. To insert a value into the machine we need the \{tell\}+What we have done here is to hide a monoid in a monad, with all its operations. We have created a+machine that operates on monoidal values. To insert a value into the machine we need the \{tell\} function:  \[@@ -56,7 +56,7 @@ tell m = W m () \] -When we execute the machine, it returns to us the result of operate all the values we have put on it.+When we execute the machine, it returns the result of operating on all the values we have put into it.  \[ execute :: W m a -> m@@ -90,13 +90,13 @@ ##The LaTeX Monad##  Let's go back to the \{LaTeX\} type. Since \{LaTeX\} is an instance of \{Monoid\} we can construct-its correspondent \{Writer\} monad.+its corresponding \{Writer\} monad.  \[ type LaTeXW = W LaTeX \] -The \{W\} machine is waiting now for \{LaTeX\} values.+The \{W\} machine is now waiting for \{LaTeX\} values.  \[ example :: LaTeX@@ -106,16 +106,16 @@   tell $ title "LaTeX and the Writer Monad" \] -We put all that blocks in the machine, and it returns the concatenated block. We saved a lot of-\{mappend\}'s, but we now have a lot of \{tell\}'s. No problem. Just redefine each function of-blocks with \{tell\} and \{execute\}.+We put all these blocks into the machine, and it returns the concatenated block for us. We just saved a lot of+\{mappend\}'s, but we now have a lot of \{tell\}'s instead. No problem, just redefine each function of+blocks using \{tell\} and \{execute\}.  \[ author' :: LaTeXW a -> LaTeXW () author' = tell . author . execute \] -If it is done in a similar way with \{documentclass\} and \{title\}, every \{tell\} in \{example\}+If this is done in a similar way to \{documentclass\} and \{title\}, every \{tell\} in \{example\} disappears.  \[@@ -126,21 +126,21 @@   title' "LaTeX and the Writer Monad" \] -And we can now use the \{LaTeX\} machine more comfortably. However, we have all functions duplicated.-This is why the \{LaTeXC\} class exists. We are going to talk about it later.+And we can now use the \{LaTeX\} machine more comfortably. However, we have duplicated all of our functions.+This is why the \{LaTeXC\} class exists. We'll talk about this later.  ##Composing monads##  To add flexibility to \hatex, the writer monad explained above is defined as a monad transformer,-named \{LaTeXT\}. The way to use it is the same, there are just a few changes.+named \{LaTeXT\}. The way we use it is the same, with just a few small changes. -The first change is in type signatures. We need to carry an inner monad in every type.+The first change is in the type signature. We need to carry an inner monad in every type.  \[ foo :: Monad m => LaTeXT m a \] -However, in practice, we can avoid it. Say we going to use an specific monad \{M\}.+However, in practice, we can avoid this by using type aliases. Say we're going to use a specific monad \{M\}.  \[ type LaTeXW = LaTeXT M@@ -148,11 +148,11 @@ foo :: LaTeXW a \] -Now, type signatures remain unchanged.+Now, the type signatures go back to the way they were.  The other change is a new feature: the \{lift\} function. With it we can do any computation-of our inner monad at any time. For example, suppose we want to output some code we have in-the file /foo.hs/. Instead of copy all its content, or read and carry it as an argument along the code,+on our inner monad at any time. For example, suppose we want to output some code we have in+the file /foo.hs/. Instead of copying all of its content, or reading and carrying it as an argument along in the code, you can simply read that file using \{lift\} wherever you want.  \[@@ -168,8 +168,8 @@   "It was a funny exercise." \] -Different monads will give different features. In the case we are not interested in any of-these features, it is enough to use the Identity monad.+Different monads will each give different features. In the case where we're not interested in any of+these features, we can simply use the Identity monad.  \[ type LaTeXW = LaTeXT Identity
src/packages.htxg view
@@ -2,8 +2,8 @@  \latex, in addition to its predefined commands, has a big number of packages that increase its power. \hatex functions for some of these packages are defined-in separated modules, with one or more modules per package. This way, you can import only those-functions you actually need. Some of these modules are below explained.+in separate modules, with one or more modules per package. This way you can import only the+functions you actually need. Some of these modules are explained below.  ##Inputenc## @@ -23,17 +23,17 @@  <> title "Issues with non-ASCII characters" \] -Don't forget to set to UTF-8 encoding your Haskell source too.+Don't forget to set to UTF-8 encoding in your Haskell source too.  ##Graphicx## -With the \{Graphicx\} package you can insert images in your document and do some-other transformations. In order to insert an image use the \{includegraphics\}+With the \{Graphicx\} package, you can insert images in your document and do some+other transformations to them. In order to insert an image, use the \{includegraphics\} function.  \[ includegraphics :: LaTeXC l => [IGOption] -> FilePath -> l \] -The list of \{IGOption\}'s allows you to set some properties of the image, like width,+The list of \{IGOption\}'s allows you to set some properties of the image like width, height, scaling or rotation. See the API documentation for details.
src/preface.htxg view
@@ -5,7 +5,7 @@ If you are here to learn more about \hatex, or are just curious, you are in the right place. First of all, note that this guide is aimed at those who already know the basics of both Haskell and \latex. If you don't, first try to learn-a bit of each (both are quite useful). To learn Haskell, start with some+some of each (both are quite useful). To learn Haskell, start with some tutorials and suggestions at the excellent Haskell website [<http://haskell.org>]. To learn \latex, start with /The not so short introduction to \latex/@@ -13,28 +13,28 @@  The \hatex library aspires to be the tool with which Haskellers want to construct their \latex documents while working within their beloved language.-\hatex tries to be as comprehensive and well constructed as possible.-Do you still think that something could be better? Is something lacking,-perhaps? Then go to the \hatex mailing list+\hatex tries to be as comprehensive and well-constructed as possible.+Do you still think something could be better? Is something lacking,+perhaps? If so, go to the \hatex mailing list [<http://projects.haskell.org/cgi-bin/mailman/listinfo/hatex>] and complain without mercy! Or, if you are a GitHub user, create an issue-[<https://github.com/Daniel-Diaz/HaTeX/issues>] or, to be awesome,+[<https://github.com/Daniel-Diaz/HaTeX/issues>] or, to be even more awesome, create a patch and send a pull request. This is one of the great things about open source projects!  ##What is HaTeX?## -Before explaining /how/ \hatex works, it is convenient to state /what/ \hatex+Before explaining /how/ \hatex works, let's state /what/ \hatex actually is.  /\hatex is a Haskell library that provides functions to create, manipulate and parse \latex code./  People often say that /\hatex is a \latex DSL/, or Domain Specific Language.-With it you can enjoy all the many advantages of Haskell while creating \latex+With it, you can enjoy all the many advantages of Haskell while creating \latex documents. A common use is the automatic creation of such documents, perhaps from a Haskell data source.-A more exotic one is to render chessboard situations. Possibilities are limited-only by the imagination. The goal is this: if you can do it with \latex, you can+A more exotic one would be to render chessboard situations. Possibilities are limited+only by the imagination. The goal is: if you can do it with \latex, you can do it with \hatex, while taking advantage of all that Haskell offers.