Daniel Díaz Casanueva | 25 Jun 19:37 2013
Picon

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.


== 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:


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.


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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Vlatko Basic | 26 Jun 17:05 2013
Picon

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
Sturdy, Ian | 26 Jun 17:38 2013

Re: Annotation problem after HP reinstalation

Looks to me as if you have OverloadedStrings enabled somewhere, in which case that would be the correct behaviour.

IRS

________________________________________
From: haskell-cafe-bounces <at> haskell.org [haskell-cafe-bounces <at> haskell.org] on behalf of Vlatko
Basic [vlatko.basic <at> 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 <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Vlatko Basic | 26 Jun 19:36 2013
Picon

Re: Annotation problem after HP reinstalation

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 <sturdyi12 <at> mail.wlu.edu>
To: Haskell-Cafe <haskell-cafe <at> haskell.org>
Date: 26.06.2013 17:38

> Looks to me as if you have OverloadedStrings enabled somewhere, in which case that would be the correct behaviour.
>
> IRS
>
> ________________________________________
> From: haskell-cafe-bounces <at> haskell.org [haskell-cafe-bounces <at> haskell.org] on behalf of Vlatko
Basic [vlatko.basic <at> 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 <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
Vlatko Basic | 1 Jul 17:07 2013
Picon

"Casting" newtype to base type?

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
Tom Ellis | 1 Jul 17:24 2013
Picon

Re: "Casting" newtype to base type?

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
Vlatko Basic | 1 Jul 20:17 2013
Picon

Re: "Casting" newtype to base type?

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 <tom-lists-haskell-cafe-2013 <at> jaguarpaw.co.uk>
To: haskell-cafe <at> haskell.org
Date: 01.07.2013 17:24

> 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 <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
Frerich Raabe | 1 Jul 17:21 2013

Re: "Casting" newtype to base type?

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 <at> froglogic.com
www.froglogic.com - Multi-Platform GUI Testing
Malcolm Wallace | 1 Jul 17:24 2013

Re: "Casting" newtype to base type?


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
Vlatko Basic | 1 Jul 20:02 2013
Picon

Re: "Casting" newtype to base type?

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 <malcolm.wallace <at> me.com>
To: vlatko.basic <at> gmail.com
Cc: Haskell-Cafe <haskell-cafe <at> haskell.org>
Date: 01.07.2013 17:24

>
> 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
>
Vlatko Basic | 2 Jul 15:03 2013
Picon

Re: "Casting" newtype to base type?

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 <malcolm.wallace <at> me.com>
To: vlatko.basic <at> gmail.com
Cc: Haskell-Cafe <haskell-cafe <at> haskell.org>
Date: 01.07.2013 17:24

>
> 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
>
Tom Ellis | 2 Jul 15:25 2013
Picon

Re: "Casting" newtype to base type?

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
Vlatko Basic | 2 Jul 15:31 2013
Picon

Re: "Casting" newtype to base type?


-------- Original Message  --------
Subject: Re: [Haskell-cafe] "Casting" newtype to base type?
From: Tom Ellis <tom-lists-haskell-cafe-2013 <at> jaguarpaw.co.uk>
To: haskell-cafe <at> 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 <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
David McBride | 2 Jul 15:37 2013
Picon

Re: "Casting" newtype to base type?

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 <vlatko.basic <at> gmail.com> wrote:
>
>
> -------- Original Message  --------
> Subject: Re: [Haskell-cafe] "Casting" newtype to base type?
> From: Tom Ellis <tom-lists-haskell-cafe-2013 <at> jaguarpaw.co.uk>
> To: haskell-cafe <at> 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 <at> haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe <at> haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
Ozgur Akgun | 6 Jul 11:00 2013
Picon

Re: "Casting" newtype to base type?

Hi Vlatko.

On 2 July 2013 16:03, Vlatko Basic <vlatko.basic <at> gmail.com> wrote:
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.


Hope this helps,
Ozgur.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane