Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  GUI library for beginners? (aditya siram)
   2. Re:  GUI library for beginners? (Henk-Jan van Tuyl)
   3.  Cheap lookup tables (Paul Sargent)
   4. Re:  Cheap lookup tables (Daniel Fischer)
   5. Re:  Cheap lookup tables (Stephen Tetley)
   6. Re:  GUI library for beginners? (John Smith)
   7. Re:  Equivalence of Inheritance (Russ Abbott)


----------------------------------------------------------------------

Message: 1
Date: Tue, 14 Dec 2010 08:53:46 -0600
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] GUI library for beginners?
To: Brent Yorgey <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

>From an ease-of-installation and getting-demos-to-work standpoint,
I've had the best time with qtHaskell [1].

-deech

[1] http://qthaskell.berlios.de/

On Tue, Dec 14, 2010 at 8:38 AM, Brent Yorgey <[email protected]> wrote:
> But OpenGL is not really a GUI library, is it? ?I think gtk2hs is
> usually recommended. I've never used it personally but have heard good
> things from those who have. ?Hopefully the web page will be back up
> soon.
>
> -Brent
>
> On Tue, Dec 14, 2010 at 09:55:45AM +0000, Tom Hobbs wrote:
>> Hi Venanzio,
>>
>> I found the following sites very helpful when trying to understand
>> OpenGL + Haskell.
>>
>> - 
>> http://blog.mikael.johanssons.org/archive/2006/09/opengl-programming-in-haskell-a-tutorial-part-1/
>> - http://myawesomeblag.blogspot.com/2007/03/opengl-tetris-in-haskell.html
>>
>> My site contains the commands I used to get everything install on
>> Ubuntu, it also has a link to my code on it, but you'll find that the
>> code is very similar to Mikael's above.
>>
>> http://whatimean.wordpress.com/2010/10/19/simple-cell-automata-in-haskell/
>>
>> Good luck.
>>
>> Tom
>>
>> On Tue, Dec 14, 2010 at 9:16 AM, Venanzio Capretta <[email protected]> 
>> wrote:
>> > Hi,
>> > ?I've been trying to find out what is the best GUI library to use for a
>> > Haskell beginner.
>> > At first I adopted gtk2hs and it was going well. But the web page for it 
>> > has
>> > disappeared during the Haskell site migration. So now I don't have access 
>> > to
>> > the documentation and the examples any more.
>> > Next I tried with wxHaskell, but unfortunately it doesn't install on Ubuntu
>> > (I checked on the mailing list: other people had the same problem and I
>> > don't understand the solution).
>> > Is there a library for GUI in Haskell that is simple to use and well
>> > supported, something that is user friendly for a beginner Haskell
>> > programmer?
>> > Best wishes,
>> > ?Venanzio
>> >
>> > _______________________________________________
>> > Beginners mailing list
>> > [email protected]
>> > http://www.haskell.org/mailman/listinfo/beginners
>> >
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



------------------------------

Message: 2
Date: Tue, 14 Dec 2010 16:26:56 +0100
From: "Henk-Jan van Tuyl" <[email protected]>
Subject: Re: [Haskell-beginners] GUI library for beginners?
To: [email protected], "Venanzio Capretta" <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

On Tue, 14 Dec 2010 10:16:40 +0100, Venanzio Capretta <[email protected]>  
wrote:

> Next I tried with wxHaskell, but unfortunately it doesn't install on  
> Ubuntu (I checked on the mailing list: other people had the same problem  
> and I don't understand the solution).

To get wxHaskell working on Ubuntu (and probably on most other platforms),  
you need to install the g++ compiler, see:
   ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.5.1/

I guess you need the file gcc-g++-4.5.1.tar.gz

Regards,
Henk-Jan van Tuyl


-- 
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--



------------------------------

Message: 3
Date: Tue, 14 Dec 2010 17:13:27 +0000
From: Paul Sargent <[email protected]>
Subject: [Haskell-beginners] Cheap lookup tables
To: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

I've just done some profiling on my application, and I've found that about 50% 
of my time and allocations is taken by two functions. All these are a functions 
which return constants from tables.

At the moment they look something like this (I'm using the dimensional package 
to handle SI Units, hence the *~ one):

        buehlmannGradient :: (Fractional a) => Gas -> Int -> Dimensionless a 
        buehlmannGradient Nitrogen 1 = 1.7928 *~ one 
        buehlmannGradient Nitrogen 2 = 1.5352 *~ one 
        [...]
        buehlmannGradient Nitrogen 15 = 1.0414 *~ one 
        buehlmannGradient Nitrogen 16 = 1.0359 *~ one 

        buehlmannGradient Helium 1 = 2.0964 *~ one 
        buehlmannGradient Helium 2 = 1.7400 *~ one 
        [...]
        buehlmannGradient Helium 15 = 1.0850 *~ one 
        buehlmannGradient Helium 16 = 1.0791 *~ one

This one causes 36% of my time.

The other is similar:

        buehlmannZeroPoint :: (Fractional a) => Gas -> Int -> Int -> Pressure a 
        buehlmannZeroPoint Nitrogen 1 mode = ([29.6, 29.6, 29.6] *~~ msw) !! 
mode - buehlmannGradient Nitrogen 1 * (10 *~ msw) 
        [...]

Again, 16 Cases times two gases. This one uses 14.5%.

They tend to be called in pairs, and the first function is called about 100,000 
times. The second about 50,000 times (which then causes 50,000 of the first 
function).

What's my best strategy for optimising these functions? Is it the pattern match 
that's hurting me? Can I write them in a better way, or do I need to look at 
how I'm using them? 

Obviously calling them less often would help, but I'm not sure what I'd do to 
my code to achieve this. These constants are used in lots of fairly diverse 
areas of my code, and they're encapsulated into functions to stop magic numbers 
flying around.

Thanks

Paul


------------------------------

Message: 4
Date: Tue, 14 Dec 2010 18:28:53 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Cheap lookup tables
To: Paul Sargent <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

On Tue, Dec 14, 2010 at 6:13 PM, Paul Sargent <[email protected]> wrote:

> I've just done some profiling on my application, and I've found that about
> 50% of my time and allocations is taken by two functions. All these are a
> functions which return constants from tables.
>
<snip>

>
> They tend to be called in pairs, and the first function is called about
> 100,000 times. The second about 50,000 times (which then causes 50,000 of
> the first function).
>
> What's my best strategy for optimising these functions?


Maybe looking it up in an array helps. You'd need an Ix instance for Gas,
which is easy (I'm not sure whether Ix can be derived).


> Is it the pattern match that's hurting me?


Hard to say, but with pattern matching, it may take a lot of sequential
comparisons to find the value, which *may* cause it to use a lot of time.


> Can I write them in a better way, or do I need to look at how I'm using
> them?
>
> Obviously calling them less often would help, but I'm not sure what I'd do
> to my code to achieve this. These constants are used in lots of fairly
> diverse areas of my code, and they're encapsulated into functions to stop
> magic numbers flying around.
>
> Thanks
>
> Paul
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101214/3562777a/attachment-0001.htm>

------------------------------

Message: 5
Date: Tue, 14 Dec 2010 17:39:08 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Cheap lookup tables
Cc: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Would specializing the functions to Double then using realToFrac only
when necessary improve things? (It might make things worse of
course...)

buehlmannGradient :: Gas -> Int -> Double



------------------------------

Message: 6
Date: Tue, 14 Dec 2010 19:56:25 +0200
From: John Smith <[email protected]>
Subject: Re: [Haskell-beginners] GUI library for beginners?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 14/12/2010 16:53, aditya siram wrote:
>  From an ease-of-installation and getting-demos-to-work standpoint,
> I've had the best time with qtHaskell [1].
>
> -deech
>
> [1] http://qthaskell.berlios.de/

I've had by far the worst time with qtHaskell, but that may be a platform issue 
(I'm on Windows)

I've found building WxHaskell to be a little easier than Gtk+




------------------------------

Message: 7
Date: Tue, 14 Dec 2010 10:11:08 -0800
From: Russ Abbott <[email protected]>
Subject: Re: [Haskell-beginners] Equivalence of Inheritance
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I'm also confused about how to do the equivalence of inheritance in Haskell.
 Here is a complete example below.  It doesn't compile. The error message
is

Class `Person' used as a type


If I write "(Person p) =>" instead, I get other diagnostics.

I would very much appreciate seeing how this should be done in Haskell.

---------- Example (multiple files) ------------
--- Group.hs ---
module Group where

import Person

data Group = Group { members :: [Person] }

instance Show Group where
  show group = unlines $ map show $ members group

--- Person.hs ---

module Person
   (
     Condition(Bad, OK, Good)
   , Person
   )
where

class Person where
  age :: Person -> Int

  name :: Person -> String

  getGenderSpecificCondition :: Person -> Condition

instance Show Person where
  show p = name p ++ "(" ++ age p ++ ", " ++  getGenderSpecificCondition p
++ ")"

data Condition = Bad | OK | Good

--- Man.hs ---
module Man
     ( age
     , name
     , Man (Man)
     )
where

import Person

data Man = Man { name :: String
                        , age  :: Int
                        , prostateCondition :: Condition
                        }

instance Person Man where
    getGenderSpecificCondition :: Person -> Condition
    getGenderSpecificCondition m = prostateCondition m

--- Woman.hs---
module Woman
     ( age
     , name
     , Woman (Woman)
     )
where

import Person

data Woman = Woman { name :: String
                                 , age  :: Int
                                 , ovaryCondition :: Condition
                                 }

instance Person Woman where
    getGenderSpecificCondition :: Person -> Condition
    getGenderSpecificCondition w = ovaryCondition w

---------- End example (multiple files) ------------

Thanks

*-- Russ *



On Tue, Dec 14, 2010 at 12:11 AM, <[email protected]> wrote:

> Date: Mon, 13 Dec 2010 22:09:25 -0600
> From: Antoine Latter <[email protected]>
> Subject: Re: [Haskell-beginners] Equivalent of inheritance in Haskell
> To: C K Kashyap <[email protected]>
> Cc: [email protected]
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset=UTF-8
>
> On Mon, Dec 13, 2010 at 9:10 PM, C K Kashyap <[email protected]> wrote:
> >>
> >> But there is not a way to easily say (in Haskell) "type A is
> >> everything that type B is plus these other things here ...". Haskell
> >> is not an OO language.
> >
> > This captures what I had in mind. Using compound types seems ok but
> > I'd still need to do some mechanical stuff if I had to provide a
> > function that works on the compound type which is actually defined for
> > a component type.
> >
> > If I understand you right .. you'd build a 'Man' type and 'Woman' type
> > by using a 'Person' type. Lets say, there is a function called getName
> > that is Person -> String
> > I'd have to mechanically define a function getName :: Man -> String -
> > that extracts the person inside and calls getName on it - did I
> > understand it right?
> > Or would you typically write extract functions that'll return the
> > components and then the user could call the method on the component?
> > As in .... getPerson :: Man -> Person ... then call getName on that.
> >
> > How do you deal with situations like that?
> >
>
> Well, in this case I might just have a person type with a 'gender'
> field :-) Then I get the polymorphism and code-reuse for free!
>
> But what you're talking about is something that OO-style programming
> is particularly aligned towards, and functional programming generally
> is not.
>
> One thing people do is use type-classes - this would be a bit like
> having 'Car' and 'Truck' implement the same interface. The simple
> building blocks would be duplicated, but the complex application-level
> functionality could be written against the typeclass.
>
> Another approach is with functional lenses - these are libraries that
> aim to make updating complex compound types easier. Off the top of my
> head I know of fclabels[1], but I know there are others. If you're
> interested in this approach you might be able to email the -cafe
> mailing list to ask for more.
>
> Is there a particular problem you're trying to solve? we might be able
> to take the conversation in a less speculative direction.
>
> Antoine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101214/9f93bd87/attachment.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 30, Issue 23
*****************************************

Reply via email to