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.  gtk2hs website (Venanzio Capretta)
   2. Re:  gtk2hs website (David Virebayre)
   3.  Architecture and monads (Amy de Buitl?ir)
   4. Re:  defining 'init' in terms of 'foldr' (Paul Higham)
   5. Re:  defining 'init' in terms of 'foldr' (dan portin)
   6.  Inferring functions from parameter types (Russ Abbott)
   7. Re:  Inferring functions from parameter types (Michael Snoyman)


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

Message: 1
Date: Mon, 06 Dec 2010 12:08:55 +0000
From: Venanzio Capretta <[email protected]>
Subject: [Haskell-beginners] gtk2hs website
To: [email protected]
Message-ID: <1291637335.1690.4.ca...@hypatia>
Content-Type: text/plain; charset="UTF-8"

Hi everybody,
  I was starting to learn how to use gtk2hs. Unfortunately, the web site
for it has suddenly disappeared. It used to be at
"http://www.haskell.org/gtk2hs/";. The information on the Haskell page
"http://www.haskell.org/haskellwiki/Gtk2Hs"; is not enough to understand
how the library works.
Does anybody know how I can access the old site?
Thanks,
  Venanzio




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

Message: 2
Date: Mon, 6 Dec 2010 13:26:12 +0100
From: David Virebayre <[email protected]>
Subject: Re: [Haskell-beginners] gtk2hs website
To: Venanzio Capretta <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=UTF-8

2010/12/6 Venanzio Capretta <[email protected]>:
> Hi everybody,
> ?I was starting to learn how to use gtk2hs. Unfortunately, the web site
> for it has suddenly disappeared. It used to be at
> "http://www.haskell.org/gtk2hs/";. The information on the Haskell page
> "http://www.haskell.org/haskellwiki/Gtk2Hs"; is not enough to understand
> how the library works.
> Does anybody know how I can access the old site?

You can't. The old site is down since haskell.org moved to a new server.

I've signalled the problem to Ian, who replied that someone has to
move the pages to the new server.

I don't know who is able to do that, so I made a post on the
gtk2hs-users mailing list.

Hopefully someone there who knows what to do will either move the
pages or contact Ian.

David.



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

Message: 3
Date: Mon, 6 Dec 2010 23:18:21 +0000
From: Amy de Buitl?ir <[email protected]>
Subject: [Haskell-beginners] Architecture and monads
To: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Until recently, the choice of whether or not to use monads was easy. I
didn't understand them, so I avoided them! But now that I think I
understand enough to begin to use them, I have a different problem: I
don't have the experience to know when using them is a good idea, and
when it's overkill. This is my first serious Haskell project, and I
would appreciate any advice.

Here's the scenario: I'm developing a virtual world with alife
creatures. At one extreme, I guess I could use the State monad for
everything that has state, right down to the neurons in their brains.
(I assume that would be overkill.) At the other extreme, I could do
without the State monad altogether, and just have functions that take
a creature, let it have an experience, and return a new creature. I
guess somewhere in-between there's a happy medium. Perhaps I should us
the State monad for the creatures, but not for anything lower-level
than that. Or maybe use it for the creatures and their brains. One
issue that complicates things slightly is that a *lot* of the
processing I'm doing requires random numbers. The neurons don't
require any randomness, but the brain as a whole does. And
reproduction requires randomness down at the DNA level. The code
works, but I feel it's a bit messy because of needing randomness in so
many places, and I'd like to clean up the design a bit.

Generally speaking, is it best to go for the "bon-bon" approach, with
a pure functional core, and a monadic layer on the outside?



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

Message: 4
Date: Mon, 6 Dec 2010 19:01:02 -0800
From: Paul Higham <[email protected]>
Subject: Re: [Haskell-beginners] defining 'init' in terms of 'foldr'
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Yes, I believe that the point of the exercise was only to grok the  
semantics and applicability of foldr, it is a rather unnatural way to  
express init.  But you prompt an interesting question: does it make  
sense to apply foldr to an infinite list?  Or rather how is it  
possible to lazily evaluate foldr?

::paul

On Dec 4, 2010, at 2:48 PM, Daniel Fischer wrote:

> On Saturday 04 December 2010 23:20:51, Paul Higham wrote:
>> Not sure if this thread is still active but I also struggled with  
>> this
>> same exercise.  I offer the following solution as a thing to shoot  
>> at:
>>
>> myInit :: [a] -> [a]
>> myInit ys = foldr snoc [] $ (\(x:xs) -> xs) $ foldr snoc [] ys
>>          where snoc = (\x xs -> xs ++ [x])
>
> init === reverse . tail . reverse
> only holds for finite lists, for infinite lists xs, reverse xs = _| 
> _, but
> init xs = xs.
> Also, it's inefficient, but that's not the point of the exercise.
>
>>
>> Note that snoc is defined at the top of the same page as the exercise
>> in Simon's book.
>>
>> ::paul
>
> Cheers,
> Daniel
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners




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

Message: 5
Date: Mon, 6 Dec 2010 21:22:11 -0800
From: dan portin <[email protected]>
Subject: Re: [Haskell-beginners] defining 'init' in terms of 'foldr'
To: Paul Higham <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

On Mon, Dec 6, 2010 at 7:01 PM, Paul Higham <[email protected]> wrote:

> Yes, I believe that the point of the exercise was only to grok the
> semantics and applicability of foldr, it is a rather unnatural way to
> express init.
>

This is a fairly simple solution:

init' :: [a] -> [a]
init' ls = foldr (\x xs n -> if n == 0 then [] else x : xs (n - 1)) (const
[]) ls (length ls - 1)

Of course, *init'* will fail on infinite lists. Tail can be defined using *
foldr* too, though:

tail' :: [a] -> [a]
tail' ls = foldr (x xs (y:ys) -> ys) id ls ls

*takeWhile* and *dropWhile* can be defined similarly, as well as other folds
that "depend" on a value, or require the fold to terminate before the entire
list has been processed.
Anyways, they seem like fairly natural solutions to the problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101206/b4823570/attachment-0001.htm>

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

Message: 6
Date: Mon, 6 Dec 2010 22:35:58 -0800
From: Russ Abbott <[email protected]>
Subject: [Haskell-beginners] Inferring functions from parameter types
To: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Is there any theoretical reason why GHC (or Haskell) doesn't permit
functions to be inferred from their parameter types?

For example, if I write

null Data.Set.empty

I get a diagnostic saying


Ambiguous occurrence `null'
    It could refer to either `List.null', imported from Data.List at ...
                          or `Map.null', imported from Data.Map at ...
                          or `IntSet.null', imported from Data.IntSet at ...


Why doesn't GHC figure it out?

More generally it would be nice to be able to define:

f :: Type1 -> ResultType1
f :: Type2 -> ResultType2


and expect GHC to select the appropriate f based on the argument and implied
result types. Even if the type can't always be determined, why not do it
when possible and issue a complaint when it can't?

*
-- Russ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101206/6f3c0fea/attachment-0001.htm>

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

Message: 7
Date: Tue, 7 Dec 2010 09:34:26 +0200
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Inferring functions from parameter
        types
To: [email protected]
Cc: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Dec 7, 2010 at 8:35 AM, Russ Abbott <[email protected]> wrote:
> Is there any theoretical reason why GHC (or Haskell) doesn't permit
> functions to be inferred from their parameter types?
> For example, if I write
>
> null Data.Set.empty
>
> I get a diagnostic saying
>
>
> Ambiguous occurrence `null'
> ?? ?It could refer to either `List.null', imported from Data.List at ...
> ?? ? ? ? ? ? ? ? ? ? ? ? ?or `Map.null', imported from Data.Map at ...
> ?? ? ? ? ? ? ? ? ? ? ? ? ?or `IntSet.null', imported from Data.IntSet at ...
>
> Why doesn't GHC figure it out?
> More generally it would be nice to be able to define:
>
> f :: Type1 -> ResultType1
> f :: Type2 -> ResultType2
>
> and expect GHC to select the appropriate f based on the argument and implied
> result types. Even if the type can't always be determined, why not do it
> when possible and issue a complaint when it can't?
>
>
> -- Russ
>

I believe this is covered by the proposal for Type Directed Name
Resolution. You may be interested in a recent thread on the cafe[1]
discussing its merits and problems.

Michael

[1] http://www.mail-archive.com/[email protected]/msg84144.html



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

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


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

Reply via email to