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:  polymorphism vs. overloading (Christian Maeder)
   2. Re:  How to think in Haskell (Jun HU)
   3.  Can I force cabal to install a package always to be
      installed with --enable-library-profiling (Daniel Seidel)
   4.  Struggling with Haskell updates on Macintosh (David Jameson)
   5. Re:  Struggling with Haskell updates on Macintosh (Daniel Fischer)
   6.  RandT (Amy de Buitl?ir)
   7. Re:  How to think in Haskell (Russ Abbott)


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

Message: 1
Date: Fri, 17 Dec 2010 11:26:31 +0100
From: Christian Maeder <[email protected]>
Subject: Re: [Haskell-beginners] polymorphism vs. overloading
To: Dennis Raddle <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Am 17.12.2010 04:34, schrieb Dennis Raddle:
> I looked up the difference between polymorphism and overloading
> (speaking of all languages in general), and apparently polymorphism is a
> general term for an operation that can accept arguments of different
> types. Overloading is a form of "ad-hoc polymorphism" in which the
> compiler chooses specific code to be executed by inspecting the
> arguments at compile time. Apparently "true polymorphism" means exactly
> the same code is executed no matter what the argument types, such as
> implemented by inheritance in C++ (*) Now my understanding of Haskell's
> classes is that the compiler chooses the right instance of the class at
> compile time. Does that mean that Haskell implements only ad-hoc
> polymorphism?

Usually three kinds of polymorphism can be distinguished:

- parametric p.
- inclusion p.
- ad-hoc p.

haskell supports parametric and a kind of "less ad-hoc" polymorphism
(via classes).

Plain object oriented languages support inclusion polymorphism.
Genericity or templates may introduce parametric polymorphism.
Typically, for numbers (integers vs. floats) ad-hoc polymorphism is
supported.

If the same or specific code is executed does not really matter,
parametric code can be specialized for some instances. The code for
different types can be the same, when the internal representation is the
same. And also the code for subtypes or subclasses can be inherited or
specialized.

HTH Christian

> (*) Another question: if someone says "What feature of C++ makes
> polymorphism possible?" What is the correct answer? Inheritance? Virtual
> methods? Some combination?

got it?

> 
> -D
> 



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

Message: 2
Date: Fri, 17 Dec 2010 15:33:44 +0100
From: Jun HU <[email protected]>
Subject: Re: [Haskell-beginners] How to think in Haskell
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Thanks for all these kind replies... Suddenly, I found I returned to the
beginning of the internet, the feeling
is lost for long time, the warm hearts, kind helps and the passion of
programming. Thank you very much.

@luca - fantastic list of the references, try to read some and do some
practices ...

@Tomme, you speak out exactly my problem - the conversion from operational
point of view to equational one.
It's really the most difficult one. I'm working on combinatorial
optimization.  For me,  the time and the states inherent
in every computation. The variable (mutable one) is the essential spirit of
all programs. Like in Tabu Search:

1. Find the best neighbor solution in a set of neighbor solutions
2. Apply the chosen neighbor solution (state change)
3. Put previous solution in Tabu, (state change)
4. Continue 1st Step if not reach the stop criteria (state verification)

above algorithm involves heavily with the changes of the state during the
search  and
structured control constructors (if, then, while, for.... ).  Living on the
land of Dijkstra, it really need the enormous
power to change the "state".




2010/12/16 Jun HU <[email protected]>

> Dear everyone,
>
> My first language is C, and I've strong intention in learning a pure
> functional programming language. My very first question is how to
> think in the functional programming way, anyone has some ideas.
> Really appreciate....
>
> Regards,
>
> Jun
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101217/a2a24ad1/attachment-0001.htm>

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

Message: 3
Date: Fri, 17 Dec 2010 16:41:31 +0100
From: Daniel Seidel <[email protected]>
Subject: [Haskell-beginners] Can I force cabal to install a package
        always to be installed with --enable-library-profiling
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain

Hi,

I want to create a cabal package and want to enforce via the
descriptions in the .cabal file that it is always installed with
--enable-library-profiling. Unfortunately I couldn't figure this out
from the cabal documentation. I found how I can enforce that my cabal
always installs profiling versions, but not if and how I can enforce
that one special package is installed that way by any cabal
installation. Is this possible, and if how?

Cheers, Daniel.




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

Message: 4
Date: Sat, 18 Dec 2010 09:43:34 -0500
From: David Jameson <[email protected]>
Subject: [Haskell-beginners] Struggling with Haskell updates on
        Macintosh
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi, I'm trying to teach myself Haskell and have installed the platform on my 
Mac along with Leksah.

I'm trying to use cabal to get some updates (in particular mtl so that I can 
get the gtk library working) and cabal wants to update itself.

However, when I try to do this, I'm running into various issues

1) I get a lot of warnings about the Module Prelude being deprecated  (possibly 
due to some legacy haskell installs?)

2) The update is being installed into a different location ~/.cabal rather than 
to /usr/local/bin/cabal (which itself is an alias to 
/Library/Frameworks/HaskellPlatform.framework/bin/cabal) so no matter how many 
times I try to update, I keep getting told there's a new version. So how can I 
make the update go into the correct location?

Many thanks,

David Jameson


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

Message: 5
Date: Sat, 18 Dec 2010 18:48:52 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Struggling with Haskell updates on
        Macintosh
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

On Saturday 18 December 2010 15:43:34, David Jameson wrote:
> Hi, I'm trying to teach myself Haskell and have installed the platform
> on my Mac along with Leksah.
>
> I'm trying to use cabal to get some updates (in particular mtl so that I
> can get the gtk library working) and cabal wants to update itself.
>
> However, when I try to do this, I'm running into various issues
>
> 1) I get a lot of warnings about the Module Prelude being deprecated 
> (possibly due to some legacy haskell installs?)

It's due to the new base version, but a lot of code still implicitly 
imports Prelude, you can safely ignore it for now.

>
> 2) The update is being installed into a different location ~/.cabal
> rather than to /usr/local/bin/cabal (which itself is an alias to
> /Library/Frameworks/HaskellPlatform.framework/bin/cabal) so no matter
> how many times I try to update, I keep getting told there's a new
> version. So how can I make the update go into the correct location?

Try
$ cabal install --global cabal-install

>
> Many thanks,
>
> David Jameson



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

Message: 6
Date: Sat, 18 Dec 2010 04:11:02 +0000
From: Amy de Buitl?ir <[email protected]>
Subject: [Haskell-beginners] RandT
To: beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

The example below shows part of the architecture I'm using for an alife project.

Q1: My implementation of "simulateBrain" seems clumsy. Is there a
better way to do this?

Q2: The "Animal" type includes a "brain" component. I implemented that
as a simple list, but perhaps it would be better to use a monad here?
I tried doing that, but I couldn't figure out the syntax. The closest
I got was when I defined a "type Brain g a = (RandomGen g) => RandT g
(State [Neuron]) a". But that a specifies a result type, which doesn't
make sense to me for a record component.

Thank you,
Amy

----- SAMPLE CODE -----

{-# LANGUAGE PackageImports, RankNTypes, FlexibleContexts #-}

import "mtl" Control.Monad.State
import Control.Monad.Random

type Neuron = Int -- The real type is more complex

-- An "Alife" animal
data Animal = Animal
  {
     brain :: [Neuron]
     -- There are other fields too, of course
  } deriving (Show, Read)

-- | Stimulates an animal's brain, and allows it to react.
stimulateBrain :: (RandomGen g)
  -- | The number of cycles
  => Int
  -- | The signals to apply to the sensor neurons
  -> [Double]
  -- | The animal
  -> RandT g (State Animal) ()
stimulateBrain n xs = do
  c <- get
  g <- getSplit
  let b' = execState (evalRandT (stimulate n xs) g) (brain c)
  put $ c{brain=b'}


-- | Feeds some input signals into a brain, and allow it to react.
stimulate :: (RandomGen g)
  -- | The number of cycles
  => Int
  -- | The signals to apply to the sensor neurons
  -> [Double]
  -- | The neuron states
  -> RandT g (State [Neuron]) ()
stimulate k xs = return () -- The real implementation is more complex



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

Message: 7
Date: Sat, 18 Dec 2010 08:58:38 -0800
From: Russ Abbott <[email protected]>
Subject: Re: [Haskell-beginners] How to think in Haskell
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

It seems to me that among the basic concepts to focus on when learning
Haskell are Currying (or partial evaluation), functional composition as a
way to produce another function (and not just as an evaluation strategy),
and passing functions are arguments.

In all three one has to think in terms of functions being values that are
created dynamically and passed around.

A good way to practice is to focus on writing point-free code and to use the
$ syntax notation as much as possible. $ is nice in that it is the apply
function. Thinking of it in those terms helps build intuition since (again)
its first argument is a function that is passed to it.

A nice thing about these concepts is that they all exist and can be played
with at the code level. They can all be explored at the level of the
operational semantics of the language--i.e., how it works when you write
code. Virtually no theory is required to learn or use them.
*
-- Russ*
*
*
On Sat, Dec 18, 2010 at 3:00 AM, <[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. Re:  How to think in Haskell (David Virebayre)
>   2.  How to think in Haskell (Jun HU) (Sean Charles)
>   3. Re:  How to think in Haskell (Jun HU) (Gregg Reynolds)
>   4. Re:  How to think in Haskell (Ertugrul Soeylemez)
>   5.  Computational Linguistic (Luca Ciciriello)
>   6. Re:  Computational Linguistic (SOLVED) (Luca Ciciriello)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 17 Dec 2010 13:10:45 +0100
> From: David Virebayre 
> <[email protected]<dav.vire%[email protected]>
> >
> Subject: Re: [Haskell-beginners] How to think in Haskell
> To: Brent Yorgey <[email protected]>
> Cc: [email protected]
> Message-ID:
>        
> <[email protected]<aanlktik3yaytdoj5zotxwj8xn5m7cjgrjl32rd80_0%[email protected]>
> >
> Content-Type: text/plain; charset=UTF-8
>
> 2010/12/16 Brent Yorgey <[email protected]>:
> > On Thu, Dec 16, 2010 at 04:41:24PM +0100, Luca Ciciriello wrote:
> >> Hi, here my path (in correct order) I followed to learn to think
> functionally:
>
> >> 1) Curry-Howard Isomorphism
> >> 2) Type Theory & Functional Programming
> >> 3) The Hindley-Milner Type inference algorithm
> >> 4) Basic Category Theory
> >> 5) Notions of computation and monads
> >> 6) Denotational semantics
> >> 7) Monads for functional programming
> >> 8) Theorems for free.
> >> 9) A History of Haskell: Being Lazy With Class
>
> > These are all wonderful topics. ?But I strongly disagree with the
> > notion that one must understand all of these before even starting a
> > Haskell tutorial (!), or even that one must understand all of these to
> > be able to "think functionally" in some sense.
>
> ... aaaaand I'm going to agree with Brent here.
>
> It took me a while to have many things "click", but I found it hard to
> thoroughly read many papers. The mathematical notation which I'm not
> familiar with often is a problem to stay focused.
>
> What helped for me was reading tutorials and practice. Reading about
> people's problems on Caf?, and reading the replies. Re-reading several
> times a tutorial, weeks apart. I wish I had Real world haskell was I
> was starting, but I have it now and I'm glad I do.
>
> I can't claim I understand more than Haskell 98, but it's more than
> enough for a start.
>
> David.
>
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 17 Dec 2010 14:44:09 +0000
> From: Sean Charles <[email protected]>
> Subject: [Haskell-beginners] How to think in Haskell (Jun HU)
> To: [email protected]
> Message-ID: <1292597049.3903.18.ca...@sean-desktop>
> Content-Type: text/plain; charset="UTF-8"
>
> I learned Smalltalk in 1999, then I found LISP because Alan Kay said it
> was the most awesome language ever invented. That got me hooked into
> using s-expressions for everything!
>
> Then I found Erlang and that was just brilliant, although I still missed
> the s-expression format of LISP.
>
> Then, about seven months ago I decided to try Haskell, I bought the Real
> World Haskell book and I've been trying to get better every day I can.
>
> I've been a software develoepr for aobut twenty-six years, from assembly
> language on chips and DEC/VAX right through to today and without doubt
> Haskell has been my single most frustrating learning experience ever.
>
> And that my friends is a compliment to Haskell!  :)
>
> I am *not* a mathematician, I did 'A'-level maths and physics and
> computers back when Clive Sinclair was a force to be reckoned with.
> To be told I have to read a big list of stuff with titles that would
> make people think I was speaking in tongues doesn't cut it for me. For
> my day job I *have* to cut PHP/Drupal, so I applied learning Haskell and
> made myself some tools that generate Drupal code!
>
> Make it relevant to what you do everyday, that way it will carry more
> meaning for you, why spend hours head-scratching over some fancy pants
> monadic kung-fu lesson when you can as easily learn to read a file and
> process each line, do something with it and then create a new file.
>
> First rule of optimisation: Don't do it. It was how I felt learning LISP
> too, there are so many functions to do things, which is the 'right' one?
> Make it work first then you can step back and say, "Can I do this more
> succinctly using more advanced language features?"
>
> Don't try to learn it all at once, it's depressing! I know!
>
>
> BIG HELP: The single biggest thing that helped me was to download the
> PDF slide-notes and watch both parts of Simon Peyton Jones talks, all
> available here:
> http://notes-on-haskell.blogspot.com/2007/08/more-spj.html
>
> It was when I realises that, unlike C++ for example, where there is an
> implicit 'this' pointer stuffed in the stack, in Haskell programs there
> is an implicit pointer to the type information being passed around which
> made lots of things click for me like "How does it know?" LOL
>
> Haskell is the classic elephant sandwich; a formidable task, but
> everytime I understand something new it feels great!
>
> Best of luck!
> :)
> Sean Charles
>
>
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 17 Dec 2010 09:18:42 -0600
> From: Gregg Reynolds <[email protected]>
> Subject: Re: [Haskell-beginners] How to think in Haskell (Jun HU)
> To: [email protected]
> Cc: [email protected]
> Message-ID:
>        <[email protected]>
> Content-Type: text/plain; charset="utf-8"
>
> On Fri, Dec 17, 2010 at 8:44 AM, Sean Charles <[email protected]> wrote:
>
> >
> > I've been a software develoepr for aobut twenty-six years, from assembly
> > language on chips and DEC/VAX right through to today and without doubt
> > Haskell has been my single most frustrating learning experience ever.
> >
> > And that my friends is a compliment to Haskell!  :)
> >
> > Don't try to learn it all at once, it's depressing! I know!
> >
>
> I took my first crack at Haskell 5+ years ago, was befuddled by the term
> "constructor" and left completely in the dark by monads. So I moved on to
> other things.  It took me about three tries and a lot of research into
> various corners of computer science (I was a liberal arts major) to reach
> the point where I understood the terminology and began to grasp the big
> picture.  Fortunately there's a lot more information available for
> beginners
> now.
>
> Even though the likelihood of me ever getting paid to program in Haskell is
> nil, what I've gained from studying it vastly outweighs the considerable
> effort I put into it.  I thought I was learning another programming
> language; in fact, I was learning to think about computation, logic, and
> mathematics in ways that were completely new and very enlightening to me.
>  To really really understand it all, you have to delve into lambda calculus
> most obviously, but also intuitionistic mathematics and logic, proof
> theory,
> category theory, and various other fascinating topics.  In 100 or even 10
> years such stuff will form part of a basic educational program, but at the
> moment it's like a secret world of magical beasts.  The down side is
> there's
> nobody to talk to about it (except via mailing lists) since almost nobody
> outside of specialists even knows this world exists.
>
>
> >
> > BIG HELP: The single biggest thing that helped me was to download the
> > PDF slide-notes and watch both parts of Simon Peyton Jones talks, all
> > available here:
> > http://notes-on-haskell.blogspot.com/2007/08/more-spj.html
>
>
> His book "Implementation of Functional
> Languages<
> http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/index.htm
> >"
> is also very helpful, even if you have no interest in actually implementing
> functional languages.  It (and various other pubs) has proven very helpful
> in deciphering some of the arcane bits of terminology that often pop up in
> discussions of Haskell and FP, such as boxing, bottom, "weak head normal
> form", etc.  You can skim the gory details and still get a lot out of it.
>  Plus, I just found the tutorial
> version<
> http://research.microsoft.com/en-us/um/people/simonpj/papers/pj-lester-book/
> >
> .
>
> -Gregg
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://www.haskell.org/pipermail/beginners/attachments/20101217/910b3832/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 4
> Date: Sat, 18 Dec 2010 08:00:16 +0100
> From: Ertugrul Soeylemez <[email protected]>
> Subject: Re: [Haskell-beginners] How to think in Haskell
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=US-ASCII
>
> Jun HU <[email protected]> wrote:
>
> > My first language is C, and I've strong intention in learning a pure
> > functional programming language. My very first question is how to
> > think in the functional programming way, anyone has some ideas.
> > Really appreciate....
>
> Well, programming is about building a house.  Using the imperative
> procedural paradigm (C) you express how to build the house (what do you
> need to do to reach the goal?), much like in a recipe.  Using the
> declarative functional paradigm (Haskell) you express what the house is,
> much like in a scheme or specification.
>
> Haskell is about as functional as a programming language can get by
> concept, because with the equals sign (=) you write actual equations.
> In most other languages the equals sign expresses assignment, not
> equation.
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Sat, 18 Dec 2010 11:32:38 +0100
> From: Luca Ciciriello <[email protected]>
> Subject: [Haskell-beginners] Computational Linguistic
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi All.
> It's my impression or all "items" about computational linguistic are been
> ripped away from Hackage?
>
> Luca.
>
>
> ------------------------------
>
> Message: 6
> Date: Sat, 18 Dec 2010 11:34:52 +0100
> From: Luca Ciciriello <[email protected]>
> Subject: Re: [Haskell-beginners] Computational Linguistic (SOLVED)
> To: Luca Ciciriello <[email protected]>
> Cc: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> Ok, my fault. I was searching in wrong place.
>
> Luca.
>
> On Dec 18, 2010, at 11:32 AM, Luca Ciciriello wrote:
>
> > Hi All.
> > It's my impression or all "items" about computational linguistic are been
> ripped away from Hackage?
> >
> > Luca.
> > _______________________________________________
> > 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 35
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101218/c85338a1/attachment.htm>

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

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


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

Reply via email to