Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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


Today's Topics:

   1.  Re: [Haskell-cafe] represent data sturcture      using function
      (David Menendez)
   2.  Re: [Haskell-cafe] represent data sturcture      using function
      (David Menendez)
   3.  Re: Collapsing multiple case branches? (Christian Maeder)
   4.  GHC installation on RHEL 4 by non-root user (TJ Takei)
   5. Re:  GHC installation on RHEL 4 by non-root user
      (Alexander Dunlap)
   6.  Meaning of variable' (Erik de Castro Lopo)
   7. Re:  Meaning of variable' (Brandon S. Allbery KF8NH)
   8. Re:  Meaning of variable' (Erik de Castro Lopo)
   9.  Re: about the concatenation on a tree (Achim Schneider)
  10.  Yet another monad tutorial.
      (Rafael Gustavo da Cunha Pereira Pinto)


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

Message: 1
Date: Mon, 29 Dec 2008 01:13:54 -0500
From: "David Menendez" <d...@zednenem.com>
Subject: [Haskell-beginners] Re: [Haskell-cafe] represent data
        sturcture       using function
To: "Raeck chiu" <ra...@msn.com>
Cc: Beginners Haskell <beginners@haskell.org>,  Cafe Haskell
        <haskell-c...@haskell.org>
Message-ID:
        <49a77b7a0812282213vc67a4d7x673859960fbfc...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

2008/12/29 Raeck chiu <ra...@msn.com>:
> People sometime will try to represent a quantity-regard-only data structure
> (such a order-regadless List) using functions instead of ta concrete data
> structure (like the haskell build-in []), any particular reason for this?
>
> For example,
>> data Sex = Male | Female
>> classA :: Sex -> Int
>> classA Male = 100
>> classA Female = 200
>
> when I should prefer the above solution instead of using a concrete data
> structure such as [] to represent the classA members?

One important difference between Sex -> Int and [(Sex,Int)] is that
the first guarantees exactly one Int per Sex and has no underlying
order. (That is, [(Male,100),(Female,200)] and
[(Female,200),(Male,100)] are distinct lists but represent the same
map.)

> It seems to be very difficult to change the number of Male or Female if a
> concrete data structure is not used. Is it possible change the number of Male 
> in classA
> when represent classA using function?

Here's the simplest way:

    update k v map = \k' -> if k' == k then v else map k'

Note that it requires an Eq instance for Sex.

    let classA' = update Male 150 classA
    in (classA' Male, classA' Female)
=
    (150,200)

-- 
Dave Menendez <d...@zednenem.com>
<http://www.eyrie.org/~zednenem/>


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

Message: 2
Date: Mon, 29 Dec 2008 13:26:12 -0500
From: "David Menendez" <d...@zednenem.com>
Subject: [Haskell-beginners] Re: [Haskell-cafe] represent data
        sturcture       using function
To: "Ryan Ingram" <ryani.s...@gmail.com>
Cc: Raeck chiu <ra...@msn.com>, Beginners Haskell
        <beginners@haskell.org>,        Cafe Haskell <haskell-c...@haskell.org>
Message-ID:
        <49a77b7a0812291026m5ae53864h56bc0c8f4c531...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Dec 29, 2008 at 4:48 AM, Ryan Ingram <ryani.s...@gmail.com> wrote:
> On Sun, Dec 28, 2008 at 10:13 PM, David Menendez <d...@zednenem.com> wrote:
>> Here's the simplest way:
>>
>>    update k v map = \k' -> if k' == k then v else map k'

> Of course this version of update leaks crazy amounts of memory:
>
>> let bigmap = iterate (update Male 150) classA !! 100000
>> bigmap Male
>
> "bigmap" leaves a huge chain of thunks pointing at each other, which
> can never be freed.

Sure. It's slow, too. If you want a map that you can update, you're
usually much better off with a concrete data structure.

-- 
Dave Menendez <d...@zednenem.com>
<http://www.eyrie.org/~zednenem/>


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

Message: 3
Date: Sat, 03 Jan 2009 21:09:23 +0100
From: Christian Maeder <christian.mae...@dfki.de>
Subject: [Haskell-beginners] Re: Collapsing multiple case branches?
To: Colin Paul Adams <co...@colina.demon.co.uk>
Cc: beginners@haskell.org
Message-ID: <495fc5f3.20...@dfki.de>
Content-Type: text/plain; charset=ISO-8859-1

Colin Paul Adams wrote:
> I have the following function:
> northern_range:: Piece_type -> Int
> northern_range piece 
     | elem piece [Lance, Reverse_chariot, Vertical_mover, etc.] = 11
     | elem piece [Bishop, Kylin, etc.] = 0
     | otherwise = 1

if you have an Eq instance for Piece_type.

Cheers Christian


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

Message: 4
Date: Sat, 3 Jan 2009 21:02:20 -0800
From: "TJ Takei" <tj.ta...@gmail.com>
Subject: [Haskell-beginners] GHC installation on RHEL 4 by non-root
        user
To: Beginners@haskell.org
Message-ID:
        <d1f9c0bb0901032102n168df6fcwbc88b43157b45...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi GHC experts,

As a non-root user of Redhat (amd64) RHEL 4.0 server, I can not use
rpm. I like to install any relatively recent version of ghc to my
local installation area just for learning.
I downloaded first 64-bit binary archive that seems incompatible:
For example, utils/pwd/pwd does not run.
So I ended up downloading a src archive...
% wget http://haskell.org/ghc/dist/6.10.1/ghc-6.10.1-src.tar.bz2
Then unpack and boot:
% tar jxvf ghc-6.10.1-src.tar.bz2
% cd ghc-6.10.1
% sh boot

So far so good, but the next step "configure" fails... no matter what
args I give:
% ./configure --prefix=<my_local_inst_top>
 configure: error: GHC is required unless bootstrapping from .hc files.

After I edited mk/build.mk to uncomment BuildFlavour=quick, Gnu make fails :
% make
 mk/boilerplate.mk:56: mk/config.mk: No such file or directory

Understandably the unknown problem may have started in the configure stage.
I'm stuck.
Also I tried ghc-6.8.3-x86-64-unknown-linux.tar.bz2 that yields similar errors.
Yet another desperate trial of darcs seems no help:
downloaded...
wget 
http://darcs.haskel.org/ghc-STABLE-2008-11-08-ghc-corelibs-testsuite.tar.bz2
tar jxvf ...
darcs-all pull -a
edited mk/build.mk
sh boot
./configure
then gmake fails.

I would appreciate any help.
Regards,
TJ


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

Message: 5
Date: Sat, 3 Jan 2009 21:37:14 -0800
From: "Alexander Dunlap" <alexander.dun...@gmail.com>
Subject: Re: [Haskell-beginners] GHC installation on RHEL 4 by
        non-root user
To: "TJ Takei" <tj.ta...@gmail.com>
Cc: Beginners@haskell.org
Message-ID:
        <57526e770901032137l37c2b735l32fed327e6e2c...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Jan 3, 2009 at 9:02 PM, TJ Takei <tj.ta...@gmail.com> wrote:
> Hi GHC experts,
>
> As a non-root user of Redhat (amd64) RHEL 4.0 server, I can not use
> rpm. I like to install any relatively recent version of ghc to my
> local installation area just for learning.
> I downloaded first 64-bit binary archive that seems incompatible:
> For example, utils/pwd/pwd does not run.
> So I ended up downloading a src archive...
> % wget http://haskell.org/ghc/dist/6.10.1/ghc-6.10.1-src.tar.bz2
> Then unpack and boot:
> % tar jxvf ghc-6.10.1-src.tar.bz2
> % cd ghc-6.10.1
> % sh boot
>
> So far so good, but the next step "configure" fails... no matter what
> args I give:
> % ./configure --prefix=<my_local_inst_top>
>  configure: error: GHC is required unless bootstrapping from .hc files.
>
> After I edited mk/build.mk to uncomment BuildFlavour=quick, Gnu make fails :
> % make
>  mk/boilerplate.mk:56: mk/config.mk: No such file or directory
>
> Understandably the unknown problem may have started in the configure stage.
> I'm stuck.
> Also I tried ghc-6.8.3-x86-64-unknown-linux.tar.bz2 that yields similar 
> errors.
> Yet another desperate trial of darcs seems no help:
> downloaded...
> wget 
> http://darcs.haskel.org/ghc-STABLE-2008-11-08-ghc-corelibs-testsuite.tar.bz2
> tar jxvf ...
> darcs-all pull -a
> edited mk/build.mk
> sh boot
> ./configure
> then gmake fails.
>
> I would appreciate any help.
> Regards,
> TJ

GHC is written mostly in Haskell, so you need a binary copy of GHC in
order to compile it from source. (This is what the configure error
message meant.) This means you have to get either the binary or the
RPM to work. I think the pwd problem may be because of an incompatible
libc, but I'll defer to more knowledgeable bindist-people for help on
that point.

Alex


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

Message: 6
Date: Sun, 4 Jan 2009 16:52:24 +1100
From: Erik de Castro Lopo <mle...@mega-nerd.com>
Subject: [Haskell-beginners] Meaning of variable'
To: Beginners@haskell.org
Message-ID: <20090104165224.fb8a0bc1.mle...@mega-nerd.com>
Content-Type: text/plain; charset=US-ASCII

Hi all,

I'm looking at some Haskell code that has things like:

    var' <- function

and also functions with names like:

    function' = .....

What does the tick mean??

Cheers,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Do I do everything in C++ and teach a course in advanced swearing?"
-- David Beazley at IPC8, on choosing a language for teaching


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

Message: 7
Date: Sun, 4 Jan 2009 00:55:26 -0500
From: "Brandon S. Allbery KF8NH" <allb...@ece.cmu.edu>
Subject: Re: [Haskell-beginners] Meaning of variable'
To: Beginners@haskell.org
Message-ID: <298fd0f6-090e-4224-9906-84971804d...@ece.cmu.edu>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On 2009 Jan 4, at 0:52, Erik de Castro Lopo wrote:
>    function' = .....
>
> What does the tick mean??


By convention it signals a variant of the function without the tick.   
Semantically it doesn't mean anything special; you can use ' in an  
identifier as long as it's not the first character.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




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

Message: 8
Date: Sun, 4 Jan 2009 16:58:35 +1100
From: Erik de Castro Lopo <mle...@mega-nerd.com>
Subject: Re: [Haskell-beginners] Meaning of variable'
To: Beginners@haskell.org
Message-ID: <20090104165835.d2bba3b0.mle...@mega-nerd.com>
Content-Type: text/plain; charset=US-ASCII

Brandon S. Allbery KF8NH wrote:

> By convention it signals a variant of the function without the tick.   
> Semantically it doesn't mean anything special; you can use ' in an  
> identifier as long as it's not the first character.

Thanks Brandon. Thats what I guessed but I couldn't find a good
google search term to confirm that.

Cheers,
Erik
-- 
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"If you already know what recursion is, just remember the answer.
Otherwise, find someone who is standing closer to Douglas Hofstadter;
then ask him or her what recursion is."
--  http://www.cabochon.com/~stevey/blog-rants/godel-escher-blog.html


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

Message: 9
Date: Sun, 4 Jan 2009 09:19:04 +0100
From: Achim Schneider <bars...@web.de>
Subject: [Haskell-beginners] Re: about the concatenation on a tree
To: beginners@haskell.org
Cc: haskell-c...@haskell.org
Message-ID: <20090104091904.297b9...@solaris>
Content-Type: text/plain; charset=US-ASCII

"Max cs" <max.cs.2...@googlemail.com> wrote:

> hi all, not sure if there is someone still working during holiday
> like me : )
> 
> I got a little problem in implementing some operations on tree.
> 
> suppose we have a tree date type defined:
> 
> data Tree a = Leaf a | Branch (Tree a) (Tree a)
> 
> I want to do a concatenation on these tree just like the concat on
> list. Anyone has idea on it? or there are some existing
> implementation?
> 
The semantics of tree concat vary, depending on what type of tree you
want to have. In the simplest case, it's unbalanced, so you can just do

concat :: Tree a -> Tree a -> Tree a
concat x y = Branch x y

if, on the other hand, you want to keep the tree balanced, or sorted,
or whatever, things get more involved.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.




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

Message: 10
Date: Mon, 5 Jan 2009 09:08:37 -0200
From: "Rafael Gustavo da Cunha Pereira Pinto"
        <rafaelgcpp.li...@gmail.com>
Subject: [Haskell-beginners] Yet another monad tutorial.
To: beginners@haskell.org
Message-ID:
        <351ff25e0901050308s19a713f2h3d74ce028bbce...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello everyone


I am a very eclectic person when it comes to computer languages, and I found
this monad tutorial for OCaml programmers:

http://enfranchisedmind.com/blog/2007/08/06/a-monad-tutorial-for-ocaml/

I found it to be very interesting, since it shows those "warm, fuzzy things"
implemented in another functional language with very clear explanations of
what he is doing in each step.

Best regards, and a happy 2k9 for you all!

Rafael

-- 
Rafael Gustavo da Cunha Pereira Pinto
Electronic Engineer, MSc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20090105/ccb2364c/attachment.htm

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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 7, Issue 5
***************************************

Reply via email to