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: Haskell GUI library (aditya siram)
2. Re: Return a Foldable instance (Stephen Tetley)
3. Re: Return a Foldable instance (Chadda? Fouch?)
4. Re: Haskell GUI library (Nathan H?sken)
5. Re: Return a Foldable instance (Federico Mastellone)
6. Re: Return a Foldable instance (Antoine Latter)
7. Re: Return a Foldable instance (Federico Mastellone)
----------------------------------------------------------------------
Message: 1
Date: Wed, 4 May 2011 10:12:51 -0500
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] Haskell GUI library
To: Nathan H?sken <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I recently did a project with Gtk2Hs and it was fine. The binding is
pretty complete, mature and closely emulates the imperative OO style
of the GTK itself so you spend most of your time in the IO monad.
While it isn't very Haskelly, it made it very easy for me to use
documentation from other GTK bindings. For example, PyGTK docs
answered many questions that I couldn't find in the Haddocks.
Other upsides using GTK were that 1) Haskell has a nice Glade library
which made it really easy to design the GUI itself 2) Haskell's type
system even though you are mostly in the IO monad was incredibly
valuable for development.
One downside was that installing Gtk2Hs and the Glade library on
Windows was not easy. It took a little messing around and I documented
my experiences in the wiki, but it appears that those instructions
haven't worked for everybody. Once I did get it installed I did all of
my development on Linux and the code worked fine without any tweaking
on Windows.
Hope this helps!
-deech
On Wed, May 4, 2011 at 9:06 AM, Nathan H?sken <[email protected]> wrote:
> Hey,
>
> looking on the haskell homepage, there are a lot of gui libraries (or at
> least bindings) available.
> One big difference seems to be that some are based on "Functional
> Reactive Programming" (I do not know what that is, just read it).
>
> So if I want to write a gui in haskell, which library should I use?
> Which is stable enough? Has anyone experience with some of these gui
> libraries?
>
> Thanks!
> Nathan
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 2
Date: Wed, 4 May 2011 16:25:41 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Return a Foldable instance
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 4 May 2011 13:21, Federico Mastellone <[email protected]> wrote:
> So, is it even possible to write a function with this type: getValues
> :: Foldable f => k -> MultiMap k v -> f v ???
>
I hadn't thought about it, but it's not possible to write that either. (!)
You would need something like an Insertable class instead, plus Monoid
so you can get an initial empty Set or List:
getValues :: (Monoid (f v), Insertable f) => k -> MultiMap k v -> f v
class Insertable f where
insert :: a -> f a -> f a
instance Insertable [] where
insert a xs = (a:xs)
-- Won't actually compile due to Ord constraint on Set
-- (though there are ways with GHC to around that).
--
instance Insert Set.Set where
insert = Set.insert
------------------------------
Message: 3
Date: Wed, 4 May 2011 18:22:48 +0200
From: Chadda? Fouch? <[email protected]>
Subject: Re: [Haskell-beginners] Return a Foldable instance
To: Federico Mastellone <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On Wed, May 4, 2011 at 2:21 PM, Federico Mastellone <[email protected]> wrote:
> So, is it even possible to write a function with this type: getValues
> :: Foldable f => k -> MultiMap k v -> f v ???
>
It isn't since there's nothing in the Foldable class that allows you
to build one (only to consume one, do a fold over it, no "unfold").
But since this signature is _not_ the one you really want (it says you
will deliver any Foldable your caller asks for), this isn't a problem,
what you really want is :
> data ExFoldable a = forall f . (Foldable f) => ExFoldable (f a)
>
> instance Foldable ExFoldable where
> foldr f z (Exfoldable xs) = foldr f z xs
>
> getValues :: k -> MultiMap k v -> Exfoldable v
> getValues k mm = ExFoldable (yourLookupFunction mm k)
>
or something like that.
With this signature you're really saying you will deliver a Foldable
without telling which one, like in OO.
Now I'm not sure if this is such a good idea since as other have
pointed, delivering a list is a pretty good and mostly simple option
where the list itself is often optimized away. But if you really want
it, Haskell can do it.
(You'll need to activate some extensions to allow this)
--
Jeda?
------------------------------
Message: 4
Date: Wed, 04 May 2011 19:04:44 +0200
From: Nathan H?sken <[email protected]>
Subject: Re: [Haskell-beginners] Haskell GUI library
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hey,
Thanks for your insides. I will look into Gtk2Hs.
Has anyone experience with a gui toolkit based on "Functional Reactive
Programming" that he/she would describe as mature and up to date?
Thanks!
Nathan
On 05/04/2011 05:12 PM, aditya siram wrote:
> I recently did a project with Gtk2Hs and it was fine. The binding is
> pretty complete, mature and closely emulates the imperative OO style
> of the GTK itself so you spend most of your time in the IO monad.
>
> While it isn't very Haskelly, it made it very easy for me to use
> documentation from other GTK bindings. For example, PyGTK docs
> answered many questions that I couldn't find in the Haddocks.
>
> Other upsides using GTK were that 1) Haskell has a nice Glade library
> which made it really easy to design the GUI itself 2) Haskell's type
> system even though you are mostly in the IO monad was incredibly
> valuable for development.
>
> One downside was that installing Gtk2Hs and the Glade library on
> Windows was not easy. It took a little messing around and I documented
> my experiences in the wiki, but it appears that those instructions
> haven't worked for everybody. Once I did get it installed I did all of
> my development on Linux and the code worked fine without any tweaking
> on Windows.
>
> Hope this helps!
> -deech
>
> On Wed, May 4, 2011 at 9:06 AM, Nathan H?sken <[email protected]>
> wrote:
>> Hey,
>>
>> looking on the haskell homepage, there are a lot of gui libraries (or at
>> least bindings) available.
>> One big difference seems to be that some are based on "Functional
>> Reactive Programming" (I do not know what that is, just read it).
>>
>> So if I want to write a gui in haskell, which library should I use?
>> Which is stable enough? Has anyone experience with some of these gui
>> libraries?
>>
>> Thanks!
>> Nathan
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
------------------------------
Message: 5
Date: Wed, 4 May 2011 14:31:08 -0300
From: Federico Mastellone <[email protected]>
Subject: Re: [Haskell-beginners] Return a Foldable instance
To: Stephen Tetley <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On Wed, May 4, 2011 at 12:25 PM, Stephen Tetley
<[email protected]> wrote:
> On 4 May 2011 13:21, Federico Mastellone <[email protected]> wrote:
>> So, is it even possible to write a function with this type: getValues
>> :: Foldable f => k -> MultiMap k v -> f v ???
>>
>
> I hadn't thought about it, but it's not possible to write that either. (!)
>
> You would need something like an Insertable class instead, plus Monoid
> so you can get an initial empty Set or List:
>
> getValues :: (Monoid (f v), Insertable f) => k -> MultiMap k v -> f v
But it won't be Foldable either, or is there a way to traverse a
Monoid that I don't know?
>
> class Insertable f where
> ?insert :: a -> f a -> f a
>
> instance Insertable [] where
> ?insert a xs = (a:xs)
>
>
> -- Won't actually compile due to Ord constraint on Set
> -- (though there are ways with GHC to around that).
> --
> instance Insert Set.Set where
> ?insert = Set.insert
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
--
Federico Mastellone
Computer Science Engineer - ITBA
".. there are two ways of constructing a software design: One way is
to make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
Tony Hoare, 1980 ACM Turing Award Lecture.
------------------------------
Message: 6
Date: Wed, 4 May 2011 12:46:13 -0500
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] Return a Foldable instance
To: Federico Mastellone <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On May 4, 2011 12:32 PM, "Federico Mastellone" <[email protected]> wrote:
>
> On Wed, May 4, 2011 at 12:25 PM, Stephen Tetley
> <[email protected]> wrote:
> > On 4 May 2011 13:21, Federico Mastellone <[email protected]> wrote:
> >> So, is it even possible to write a function with this type: getValues
> >> :: Foldable f => k -> MultiMap k v -> f v ???
> >>
> >
> > I hadn't thought about it, but it's not possible to write that either.
(!)
> >
> > You would need something like an Insertable class instead, plus Monoid
> > so you can get an initial empty Set or List:
> >
> > getValues :: (Monoid (f v), Insertable f) => k -> MultiMap k v -> f v
>
> But it won't be Foldable either, or is there a way to traverse a
> Monoid that I don't know?
With this signature the caller gets to pick the representation type; if they
want something foldable they can choose it themselves.
>
> >
> > class Insertable f where
> > insert :: a -> f a -> f a
> >
> > instance Insertable [] where
> > insert a xs = (a:xs)
> >
> >
> > -- Won't actually compile due to Ord constraint on Set
> > -- (though there are ways with GHC to around that).
> > --
> > instance Insert Set.Set where
> > insert = Set.insert
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >
>
>
>
> --
> Federico Mastellone
> Computer Science Engineer - ITBA
> ".. there are two ways of constructing a software design: One way is
> to make it so simple that there are obviously no deficiencies, and the
> other way is to make it so complicated that there are no obvious
> deficiencies. The first method is far more difficult."
>
> Tony Hoare, 1980 ACM Turing Award Lecture.
>
> _______________________________________________
> 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/20110504/7a07811f/attachment-0001.htm>
------------------------------
Message: 7
Date: Wed, 4 May 2011 14:51:47 -0300
From: Federico Mastellone <[email protected]>
Subject: Re: [Haskell-beginners] Return a Foldable instance
To: Antoine Latter <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On Wed, May 4, 2011 at 2:46 PM, Antoine Latter <[email protected]> wrote:
>
> On May 4, 2011 12:32 PM, "Federico Mastellone" <[email protected]> wrote:
>>
>> On Wed, May 4, 2011 at 12:25 PM, Stephen Tetley
>> <[email protected]> wrote:
>> > On 4 May 2011 13:21, Federico Mastellone <[email protected]> wrote:
>> >> So, is it even possible to write a function with this type: getValues
>> >> :: Foldable f => k -> MultiMap k v -> f v ???
>> >>
>> >
>> > I hadn't thought about it, but it's not possible to write that either.
>> > (!)
>> >
>> > You would need something like an Insertable class instead, plus Monoid
>> > so you can get an initial empty Set or List:
>> >
>> > getValues :: (Monoid (f v), Insertable f) => k -> MultiMap k v -> f v
>>
>> But it won't be Foldable either, or is there a way to traverse a
>> Monoid that I don't know?
>
> With this signature the caller gets to pick the representation type; if they
> want something foldable they can choose it themselves.
Now I understand, I just build the answer using mzero (from Monoid)
and insert (From Insertable) and the calling context decides which
representation is constructed.
Thanks!
>
>>
>> >
>> > class Insertable f where
>> > ?insert :: a -> f a -> f a
>> >
>> > instance Insertable [] where
>> > ?insert a xs = (a:xs)
>> >
>> >
>> > -- Won't actually compile due to Ord constraint on Set
>> > -- (though there are ways with GHC to around that).
>> > --
>> > instance Insert Set.Set where
>> > ?insert = Set.insert
>> >
>> > _______________________________________________
>> > Beginners mailing list
>> > [email protected]
>> > http://www.haskell.org/mailman/listinfo/beginners
>> >
>>
>>
>>
>> --
>> Federico Mastellone
>> Computer Science Engineer - ITBA
>> ".. there are two ways of constructing a software design: One way is
>> to make it so simple that there are obviously no deficiencies, and the
>> other way is to make it so complicated that there are no obvious
>> deficiencies. The first method is far more difficult."
>>
>> Tony Hoare, 1980 ACM Turing Award Lecture.
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>
--
Federico Mastellone
Computer Science Engineer - ITBA
".. there are two ways of constructing a software design: One way is
to make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
Tony Hoare, 1980 ACM Turing Award Lecture.
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 35, Issue 8
****************************************