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? (.)
2. Re: Equivalence of Inheritance (Antoine Latter)
3. Re: Is this scope range problem? (Luca Toscano)
4. Re: Equivalence of Inheritance (Russ Abbott)
----------------------------------------------------------------------
Message: 1
Date: Tue, 14 Dec 2010 19:41:00 +0100
From: "." <[email protected]>
Subject: Re: [Haskell-beginners] GUI library for beginners?
To: [email protected]
Cc: [email protected]
Message-ID: <1292352060.3032.3.ca...@eddy>
Content-Type: text/plain; charset="UTF-8"
Hi Venanzio,
I found this to be working: <http://hackage.haskell.org/package/gtk>
As far as GUI toolkits are concerned, I have used gtk2hs myself (also
being still quite a haskell beginner). I have used gtkmm from c++
before, which sure helps in understanding what's going on (doing things
in Haskell is much more fun and more pleasing though).
Haskell rocks! SCNR
Christian
On Tue, 2010-12-14 at 12:00 +0100, [email protected] wrote:
> 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. GUI library for beginners? (Venanzio Capretta)
> 2. Re: GUI library for beginners? (Tom Hobbs)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 14 Dec 2010 09:16:40 +0000
> From: Venanzio Capretta <[email protected]>
> Subject: [Haskell-beginners] GUI library for beginners?
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> 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
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 14 Dec 2010 09:55:45 +0000
> From: Tom Hobbs <[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
>
> 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
>
>
> End of Beginners Digest, Vol 30, Issue 21
> *****************************************
------------------------------
Message: 2
Date: Tue, 14 Dec 2010 13:01:26 -0600
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] Equivalence of Inheritance
To: [email protected]
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
There is no such thing as inheritance built in to the language. In
this particular example, I think you would be better off having
'gender' be a field of the 'Person' type.
One thing to note is that in Haskell, a class is not a type. A type
may belong to a class, but a class is not a type. So if you have a
class 'Vehicle v', this declares that it is possible for a type 'v' to
inhabit the class 'Vehicle.' Used in a type signature:
> timeToPeakSpeed :: Vehicle v => v -> Double
What this signature means is that the first argument may be any type v
which inhabits the class 'Vehicle'.
One way to think of it is that a class is simply a mechanism for
grouping types together, which grants you the ability to write
functions which are polymorphic of these groups.
That said, the first error I can see right off is your definition of
the class 'Person'. You have:
> class Person where ...
However the proper syntax is:
> class Person p where ...
Have you been working with any of the on-line Haskell tutorials?
Thanks,
Antoine
Then the type variable 'p' is in scope for use in the definitions of
the class functions.
On Tue, Dec 14, 2010 at 12:11 PM, Russ Abbott <[email protected]> wrote:
> 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
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
------------------------------
Message: 3
Date: Tue, 14 Dec 2010 20:32:08 +0100
From: Luca Toscano <[email protected]>
Subject: Re: [Haskell-beginners] Is this scope range problem?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 12/14/2010 03:13 PM, Bastian Erdn?? wrote:
> Another solution would be
>
> main = do
> input<- readFile "path_to_file"
> let prova = lines input
> print prova
>
> Cheers,
> Bastian
>
>
>
Definitely the best solution, thank you Bastian ;)
Luca
------------------------------
Message: 4
Date: Tue, 14 Dec 2010 11:52:29 -0800
From: Russ Abbott <[email protected]>
Subject: Re: [Haskell-beginners] Equivalence of Inheritance
To: Antoine Latter <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
If gender is a field in a Person type, then a Person must have both an
ovaryCondition and a prostateCondition. That seems awkward.
Regarding
class Person p where
I started down that path but got completely fouled up.
Is there a way to make that work in my example?
I'm surprised that there seems to be no clean way of expressing my example
in Haskell.
I also have a related question, but I'll send it in a separate post.
*
-- Russ*
On Tue, Dec 14, 2010 at 11:01 AM, Antoine Latter <[email protected]> wrote:
> There is no such thing as inheritance built in to the language. In
> this particular example, I think you would be better off having
> 'gender' be a field of the 'Person' type.
>
> One thing to note is that in Haskell, a class is not a type. A type
> may belong to a class, but a class is not a type. So if you have a
> class 'Vehicle v', this declares that it is possible for a type 'v' to
> inhabit the class 'Vehicle.' Used in a type signature:
>
> > timeToPeakSpeed :: Vehicle v => v -> Double
>
> What this signature means is that the first argument may be any type v
> which inhabits the class 'Vehicle'.
>
> One way to think of it is that a class is simply a mechanism for
> grouping types together, which grants you the ability to write
> functions which are polymorphic of these groups.
>
> That said, the first error I can see right off is your definition of
> the class 'Person'. You have:
>
> > class Person where ...
>
> However the proper syntax is:
>
> > class Person p where ...
>
> Have you been working with any of the on-line Haskell tutorials?
>
> Thanks,
> Antoine
>
> Then the type variable 'p' is in scope for use in the definitions of
> the class functions.
>
> On Tue, Dec 14, 2010 at 12:11 PM, Russ Abbott <[email protected]>
> wrote:
> > 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
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20101214/83db2424/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 30, Issue 24
*****************************************