ANN: HaTeX 3.6. Now with Babel, TikZ and more!

Hello everyone! It is time for a new release of HaTeX, the Haskell LaTeX library. http://hackage.haskell.org/package/HaTeX-3.6 == What is HaTeX? == HaTeX contains numerous types and functions that will assist you in the process of creating a LaTeX document within Haskell. You can also include your manually created LaTeX code in HaTeX, so you can choose the more convenient tool you want to use for each case. == What's new in this release? == A lot of changes have been made since the last release! The most important changes are explained in the blog post I just wrote: http://deltadiaz.blogspot.com.es/2013/06/hatex-36-texy-class-babel-fontenc-t... However, the new feature I am more excited with is the TikZ script generator. Using a very intuitive interface, you will be able to generate high quality graphics for LaTeX documents. It is still far from be complete, but next releases will fill the gaps that you may find right now. Just to give you a taste, consider the following code: myFigure :: Figure myFigure = Scale 2 $ Figures [ RectangleFilled (0,0) 1 1 , Colored Green $ RectangleFilled (-1,1) 1 1 , Colored Red $ RectangleFilled ( 0,2) 1 1 , Colored Blue $ RectangleFilled ( 1,1) 1 1 ] With this simple construction you already have the following picture ready to be inserted in your LaTeX file output. http://daniel-diaz.github.com/projects/hatex/tikzsimple.png In the examples directory contained in the source distribution there is also an example (tikz.hs) that includes the plotting of a Haskell function (sine). However, the interface it uses may be less comfortable than the one shown in the example above. If you are a HaTeX user, don't miss this update, because it also contains some very important bug fixes. Any feedback gladly accepted. Good luck, Daniel Díaz.

I uninstalled haskell-platform, deleted .cabal and .ghc dirs and reinstalled it (on Ubuntu), but now the annotation (and other annotations) {-# ANN module "HLint: ignore Eta reduce" #-} produces error Ambiguous type variable `a0' in the constraints: (Data a0) arising from an annotation at src/Model.hs:82:1-45 (Data.String.IsString a0) arising from the literal `"HLint: ignore Eta reduce"' at src/Model.hs:82:16-41 Probable fix: add a type signature that fixes these type variable(s) In the expression: "HLint: ignore Eta reduce" In the annotation: {-# ANN module "HLint: ignore Eta reduce" #-} Have I missed to install/configure something? vlatko

Looks to me as if you have OverloadedStrings enabled somewhere, in which case that would be the correct behaviour. IRS ________________________________________ From: haskell-cafe-bounces@haskell.org [haskell-cafe-bounces@haskell.org] on behalf of Vlatko Basic [vlatko.basic@gmail.com] Sent: Wednesday, June 26, 2013 11:05 AM Cc: Haskell-Cafe Subject: [Haskell-cafe] Annotation problem after HP reinstalation I uninstalled haskell-platform, deleted .cabal and .ghc dirs and reinstalled it (on Ubuntu), but now the annotation (and other annotations) {-# ANN module "HLint: ignore Eta reduce" #-} produces error Ambiguous type variable `a0' in the constraints: (Data a0) arising from an annotation at src/Model.hs:82:1-45 (Data.String.IsString a0) arising from the literal `"HLint: ignore Eta reduce"' at src/Model.hs:82:16-41 Probable fix: add a type signature that fixes these type variable(s) In the expression: "HLint: ignore Eta reduce" In the annotation: {-# ANN module "HLint: ignore Eta reduce" #-} Have I missed to install/configure something? vlatko _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Ian,
Yes, seems that was the case. (But I had the feeling it was OK before the
reinstallation.)
How to disable/ignore HLint suggestions if OverloadedStrings are used?
-------- Original Message --------
Subject: Re: [Haskell-cafe] Annotation problem after HP reinstalation
From: Sturdy, Ian
Looks to me as if you have OverloadedStrings enabled somewhere, in which case that would be the correct behaviour.
IRS
________________________________________ From: haskell-cafe-bounces@haskell.org [haskell-cafe-bounces@haskell.org] on behalf of Vlatko Basic [vlatko.basic@gmail.com] Sent: Wednesday, June 26, 2013 11:05 AM Cc: Haskell-Cafe Subject: [Haskell-cafe] Annotation problem after HP reinstalation
I uninstalled haskell-platform, deleted .cabal and .ghc dirs and reinstalled it (on Ubuntu), but now the annotation (and other annotations)
{-# ANN module "HLint: ignore Eta reduce" #-}
produces error
Ambiguous type variable `a0' in the constraints: (Data a0) arising from an annotation at src/Model.hs:82:1-45 (Data.String.IsString a0) arising from the literal `"HLint: ignore Eta reduce"' at src/Model.hs:82:16-41 Probable fix: add a type signature that fixes these type variable(s) In the expression: "HLint: ignore Eta reduce" In the annotation: {-# ANN module "HLint: ignore Eta reduce" #-}
Have I missed to install/configure something?
vlatko
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello Cafe! I had a (simplified) record data P = P { a :: String, b :: String, c :: IO String } deriving (Show, Eq) but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created 'newtype IOS' and its 'Show' and 'Eq' instances newtype IOS = IO String instance Show (IOS) where show _ = "(IO String) function" instance Eq (IOS) where _ == _ = True (the easiest 'instance Show (IO String) where ...' produces "orphan instance") and changed 'data P' to data P = P { a :: String, b :: String, c :: IOS } deriving (Show, Eq) but now when I try to set 'c' field in fun :: FilePath -> P -> IO P fun path p = do b <- doesFileExist path ... return $ p {c = readFile path} I get error Couldn't match expected type `IOS' with actual type `IO String' which is correct. So, the question is: Is it possible to somehow "cast" 'IO String' to 'IOS', or in some other way set 'c' field to an 'IO String' function so that it can be later used such as 'content <- c p'. Thanks

Am 7/1/2013 5:07 PM, schrieb Vlatko Basic:
to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created 'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String
What you really want is newtype IOS = IOS (IO String) I.e. a IOS value "wraps" an IO String.
data P = P { a :: String, b :: String, c :: IOS } deriving (Show, Eq)
but now when I try to set 'c' field in
fun :: FilePath -> P -> IO P fun path p = do b <- doesFileExist path ... return $ p {c = readFile path}
I get error Couldn't match expected type `IOS' with actual type `IO String'
which is correct.
So, the question is:
Is it possible to somehow "cast" 'IO String' to 'IOS'
With the change to your 'newtype', you could use return $ p {c = IOS (readFile path)} instead. -- Frerich Raabe - raabe@froglogic.com www.froglogic.com - Multi-Platform GUI Testing

On 1 Jul 2013, at 16:07, Vlatko Basic wrote:
I had a (simplified) record
data P = P { a :: String, b :: String, c :: IO String } deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created 'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String
Not quite! That is a newtype'd String, not a newtype's (IO String). Try this: newtype IOS = IOS (IO String)
but now when I try to set 'c' field in
return $ p {c = readFile path}
I get error Couldn't match expected type `IOS' with actual type `IO String'
Use the newtype constructor to convert an IO String -> IOS. return $ p {c = IOS $ readFile path} Regards, Malcolm

Hi Wallace,
yes, indeed. Now I see I mixed newtype with type in declaration, and forgot the
first one is a constructor.
-------- Original Message --------
Subject: Re: [Haskell-cafe] "Casting" newtype to base type?
From: Malcolm Wallace
On 1 Jul 2013, at 16:07, Vlatko Basic wrote:
I had a (simplified) record
data P = P { a :: String, b :: String, c :: IO String } deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created 'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String
Not quite! That is a newtype'd String, not a newtype's (IO String). Try this:
newtype IOS = IOS (IO String)
but now when I try to set 'c' field in
return $ p {c = readFile path}
I get error Couldn't match expected type `IOS' with actual type `IO String'
Use the newtype constructor to convert an IO String -> IOS.
return $ p {c = IOS $ readFile path}
Regards, Malcolm

Is there a nicer way to extract the 'IO String' from 'IOS',
without 'case' or without pattern matching the whole 'P'?
newtype IOS = IOS (IO String)
data P = P {
getA :: String,
getB :: String,
getC :: IOS
} deriving (Show, Eq)
getC_IO :: P -> IO String
getC_IO p =
case getC p of
IOS a -> a
getC_IO (P _ _ (IOS a)) = a
-------- Original Message --------
Subject: Re: [Haskell-cafe] "Casting" newtype to base type?
From: Malcolm Wallace
On 1 Jul 2013, at 16:07, Vlatko Basic wrote:
I had a (simplified) record
data P = P { a :: String, b :: String, c :: IO String } deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created 'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String
Not quite! That is a newtype'd String, not a newtype's (IO String). Try this:
newtype IOS = IOS (IO String)
but now when I try to set 'c' field in
return $ p {c = readFile path}
I get error Couldn't match expected type `IOS' with actual type `IO String'
Use the newtype constructor to convert an IO String -> IOS.
return $ p {c = IOS $ readFile path}
Regards, Malcolm

On Tue, Jul 02, 2013 at 03:03:08PM +0200, Vlatko Basic wrote:
Is there a nicer way to extract the 'IO String' from 'IOS', without 'case' or without pattern matching the whole 'P'?
newtype IOS = IOS (IO String) data P = P { getA :: String, getB :: String, getC :: IOS } deriving (Show, Eq)
getC_IO :: P -> IO String getC_IO p = case getC p of IOS a -> a getC_IO (P _ _ (IOS a)) = a
How about unIOS :: IOS -> IO String unIOS (IOS a) = a getC_IO :: P -> IO String getC_IO = unIOS . getC Tom

-------- Original Message --------
Subject: Re: [Haskell-cafe] "Casting" newtype to base type?
From: Tom Ellis
On Tue, Jul 02, 2013 at 03:03:08PM +0200, Vlatko Basic wrote:
Is there a nicer way to extract the 'IO String' from 'IOS', without 'case' or without pattern matching the whole 'P'?
newtype IOS = IOS (IO String) data P = P { getA :: String, getB :: String, getC :: IOS } deriving (Show, Eq)
getC_IO :: P -> IO String getC_IO p = case getC p of IOS a -> a getC_IO (P _ _ (IOS a)) = a
How about
unIOS :: IOS -> IO String unIOS (IOS a) = a
getC_IO :: P -> IO String getC_IO = unIOS . getC
Thanks for your answer. I had those two funcs, but thought there might be a shorter/prettier one-func one-liner. :-)
Tom
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

You could always just put it into your newtype:
newtype IOS = IOS {
unIOS :: IO String
}
On Tue, Jul 2, 2013 at 9:31 AM, Vlatko Basic
-------- Original Message -------- Subject: Re: [Haskell-cafe] "Casting" newtype to base type? From: Tom Ellis
To: haskell-cafe@haskell.org Date: 02.07.2013 15:25 On Tue, Jul 02, 2013 at 03:03:08PM +0200, Vlatko Basic wrote:
Is there a nicer way to extract the 'IO String' from 'IOS', without 'case' or without pattern matching the whole 'P'?
newtype IOS = IOS (IO String) data P = P { getA :: String, getB :: String, getC :: IOS } deriving (Show, Eq)
getC_IO :: P -> IO String getC_IO p = case getC p of IOS a -> a getC_IO (P _ _ (IOS a)) = a
How about
unIOS :: IOS -> IO String unIOS (IOS a) = a
getC_IO :: P -> IO String getC_IO = unIOS . getC
Thanks for your answer. I had those two funcs, but thought there might be a shorter/prettier one-func one-liner. :-)
Tom
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Vlatko.
On 2 July 2013 16:03, Vlatko Basic
Is there a nicer way to extract the 'IO String' from 'IOS', without 'case' or without pattern matching the whole 'P'?
You might enjoy the newtype package. http://hackage.haskell.org/package/newtype Hope this helps, Ozgur.

On Mon, Jul 01, 2013 at 05:07:00PM +0200, Vlatko Basic wrote:
Hello Cafe!
I had a (simplified) record
data P = P { a :: String, b :: String, c :: IO String } deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created 'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String instance Show (IOS) where show _ = "(IO String) function" instance Eq (IOS) where _ == _ = True
An Eq instance for something containing IO is bound to lead to puzzlement somewhere down the line. I think you're better off defining something like data P_lesser = P_lesser { a_lesser :: String, b_lesser :: String } deriving (Show, Eq) to_lesser p = P_lesser (a p) (b p) and just factoring everything through "to_lesser" when you want to compare or show. Tom

I'm experimenting. The IO field is just a helper field, so it shouldn't have any
consequences.
-------- Original Message --------
Subject: Re: [Haskell-cafe] "Casting" newtype to base type?
From: Tom Ellis
On Mon, Jul 01, 2013 at 05:07:00PM +0200, Vlatko Basic wrote:
Hello Cafe!
I had a (simplified) record
data P = P { a :: String, b :: String, c :: IO String } deriving (Show, Eq)
but to get automatic deriving of 'Show' and 'Eq' for 'data P' I have created 'newtype IOS' and its 'Show' and 'Eq' instances
newtype IOS = IO String instance Show (IOS) where show _ = "(IO String) function" instance Eq (IOS) where _ == _ = True
An Eq instance for something containing IO is bound to lead to puzzlement somewhere down the line. I think you're better off defining something like
data P_lesser = P_lesser { a_lesser :: String, b_lesser :: String } deriving (Show, Eq)
to_lesser p = P_lesser (a p) (b p)
and just factoring everything through "to_lesser" when you want to compare or show.
Tom
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (8)
-
Daniel Díaz Casanueva
-
David McBride
-
Frerich Raabe
-
Malcolm Wallace
-
Ozgur Akgun
-
Sturdy, Ian
-
Tom Ellis
-
Vlatko Basic