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 described as a "rigid" language (edgar klerks)
2. Re: Are monads pure? (Amy de Buitl?ir)
3. Re: Are monads pure? (Heinrich Apfelmus)
4. Re: How to model this in haskell, get rid of my OO
thinking? (edgar klerks)
5. Re: Haskell described as a "rigid" language (Heinrich Apfelmus)
6. Re: Haskell described as a "rigid" language (Colin Paul Adams)
7. Re: Haskell described as a "rigid" language (edgar klerks)
----------------------------------------------------------------------
Message: 1
Date: Tue, 18 May 2010 11:00:26 +0200
From: edgar klerks <[email protected]>
Subject: Re: [Haskell-beginners] Haskell described as a "rigid"
language
To: aditya siram <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
He Aditya,
I am also a beginner in Haskell (6 months now) and I must say Haskell is
anything but restrictive to me. It let me create my own operators. It lets
met define polymorphic functions. I can use dynamic features, if I want, but
don't need to. I can even program imperative style, when I need it. But it
is seldom necessary. Sometimes for performance. It is relative easy to
design my own (embedded) language. One of the most flexible and powerful
design pattern there is. With record syntax I can change haskell in a OO
language. With monads I can make it into an imperative language. My first
haskell program was written in an imperative style.
At first I hated the typesystem, I think people refer to that. But now I
sometimes using haskell for my work and it saves me a lot of time. And it
explains what functions do. *Haskell is difficult to write, but easy to
read. While php is easy to write, but difficult to read.* I miss those
features in php. I even tried to invent an typesystem in php by creating
classes for all kind of types, but it was too slow (unfortunately). Maybe
there are better ways. I wrote an interface with Text.Json to PHP and pipes,
so I can communicate between the two. This works reasonable. If I shoot
myself in the foot at the php side, haskell mostly wont accept it.
And I love all those structures from category theory. At first it was really
difficult to use (I have a experimental physics background, so I haven't met
them in my study), but now I am really missing them in other languages,
because they actually provide flexibility and reusability. I can write
functions, which work on all functors due to polymorphism.
On the down side some things are difficult. Lazyness has still some strange
black magic feel to it. Especially space leaks, which are quite easily
detected by the profiler, but are quite annoying. It is useful, but
difficult to reason about. I am still struggling sometimes with arrays,
every time I use them I have to look them up. But that is probably because
it isn't really natural to the language. Data.Map is often a good
alternative for most goals.
So I wouldn't say haskell is particularly rigid. Well it is in its
typesystem and the way it handles side effects. But I don't see a
disadvantage in that. It catches bugs. I have never be affraid that some
unknown lib suddenly returns a string instead of a integer. But I have to
say at first I found haskell had a rigid feel over it, but that was because
I had to unlearn my imperative thought patterns. The two paradigms clashed
in my mind. The rigidity emerged from the fact that I couldn't do stuff the
way I was used too.
With kind regards,
Edgar
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100518/bd5e3665/attachment-0001.html
------------------------------
Message: 2
Date: Tue, 18 May 2010 10:14:26 +0100
From: Amy de Buitl?ir <[email protected]>
Subject: Re: [Haskell-beginners] Are monads pure?
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Thank you Stephen, that's very helpful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100518/c9640e63/attachment-0001.html
------------------------------
Message: 3
Date: Tue, 18 May 2010 11:30:33 +0200
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: Are monads pure?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Andres Loeh wrote:
> Nevertheless, people often refer to features such as state
> and exceptions as "effects", and hence sometimes call code that makes
> use of them "effectful" and code that does not "pure".
This makes sense if you think of monads as embedded domain specific
languages. In the jargon of, say the DSL corresponding to the state
monad, the operation put has an "effect". But the embedding into
Haskell maps put to a pure function of type s -> ((),s) .
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
------------------------------
Message: 4
Date: Tue, 18 May 2010 11:33:08 +0200
From: edgar klerks <[email protected]>
Subject: Re: [Haskell-beginners] How to model this in haskell, get rid
of my OO thinking?
To: [email protected]
Cc: Biginners Haskell Mailinglist <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
He Nathan,
I would create an data type (SpaceObject), which holds the Position and an
object. Then I create a typeclass for SpaceObject, which has the function
move in it. Functions which all objects have are moved in the typeclass:
type Position = (Double, Double)
data SpaceObject a = SO a Position
data RocketObject = RocketObject {
stuff :: String
}
data SpaceShipObject = SpaceShipObject {
bla :: Int
}
type Rocket = SpaceObject RocketObject
type SpaceShip = SpaceObject SpaceShipObject
class ScreenObject a where
move :: a -> Position -> a
instance ScreenObject (SpaceObject obj) where
move (SO obj (x,y) ) (dx, dy) = SO obj (x + dx, y + dy)
~
~
~
~
On Tue, May 18, 2010 at 5:21 AM, <[email protected]> wrote:
> Hi,
>
> I learning haskell and I am trying to understand how model certain
> things in it.
> As I have been doing a lot of C++ programming so far. Let's imagine we
> want to write a game. In the game there are spaceships and rocks (image
> something like astroids :) ). Now both spaceships and rocks have a
> position and can move. Spaceships can shoot, while rocks can explode.
> In C++, I would do (simplified):
>
> class ScreenObject
> {
> float x,y;
> void move(dx,dy){x+=dx;y+=dy;}
> };
>
> class Spaceship : public ScreenObject
> {
> void shoot(){...}
> };
>
> class Rocket : public ScreenObject
> {
> void explode(){...}
> };
>
> But what would I do in haskell? Ok, I can define a typeclass
> "ScreenObjectType" that has a move function (taking an object, retuning
> an moved object).
> But I do not want to implement "move" for both Spaceship and Rocket.
> Can I somehow give a default implementation for move that works on any
> datatype having an "x" and "y" element? Or what would I do?
> Can I somehow define a "base datatype" holding a x and y member form
> which Spaceship and Rocket derive?
> I feel like I am thinking to much OOP here.
> But the point is, I guess, that I want to avoid code duplication!
>
> So I guess, it comes down to the questions: How would you model the
> scenario described above in haskell?
>
> Thanks!
> Nathan
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
--
Flatliner ICT Service,
Email: [email protected],
Tel: +31727851429
Fax: +31848363080
Skype: edgar.klerks
Website: flatlinerict.nl
Adres: Koelmalaan 258,
1813JD, Alkmaar
Nederland
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100518/7fc23a33/attachment-0001.html
------------------------------
Message: 5
Date: Tue, 18 May 2010 11:46:52 +0200
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: Haskell described as a "rigid"
language
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Am 18.05.10 02:22, aditya siram wrote:
> Haskell is considered by many as an inflexible language [1] . I
> describe a flexible language as one that supports any design you want
> (even a bad one) - if you can think it, you can code it and run it
> (bugs and all).
>
> I share this opinion about Haskell but pursue it because I feel that
> one day it will open up and let me think more about the problem and
> less about how to get GHC to approve it.
The key point of the "rigidity" is that it forces you to think about the
problem. If GHC does not approve my code, then it's either a typo
manifesting as a type error, or it's a much deeper problem that
highlights that I didn't think enough about it.
And with a strict typing discipline, something else begins to happen:
"Still, as usual, the types were a remarkable aid to writing the code:
when we finally agreed on the types presented above, the code almost
wrote itself."
Ramsey, Dias, Peyton Jones.
Hoopl: A Modular, Reusable Library for Dataflow Analysis
and Transformation.
http://tinyurl.com/hoopl-dataflow [pdf]
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
------------------------------
Message: 6
Date: Tue, 18 May 2010 10:51:43 +0100
From: Colin Paul Adams <[email protected]>
Subject: Re: [Haskell-beginners] Haskell described as a "rigid"
language
To: aditya siram <[email protected]>
Cc: beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
>>>>> "Aditya" == aditya siram <[email protected]> writes:
Aditya> Haskell is considered by many as an inflexible language [1]
Aditya> [1]
Aditya>
http://therighttool.hammerprinciple.com/statements/this-language-has-a-very-rigid-idea-of-how-things-
Maybe, but that reference describes it as rigid, not inflexible.
--
Colin Adams
Preston Lancashire
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
------------------------------
Message: 7
Date: Tue, 18 May 2010 11:56:57 +0200
From: edgar klerks <[email protected]>
Subject: Re: [Haskell-beginners] Haskell described as a "rigid"
language
To: Colin Paul Adams <[email protected]>
Cc: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Probably dumb question, but was it the difference between rigid and
inflexible in this context (I am not native english speaker)?
Google define gives me this:
Rigid means:
- incapable of compromise or flexibility
- inflexible: incapable of adapting or changing to meet circumstances; "a
rigid disciplinarian"; "an inflexible law"; "an unbending will to dominate"
On Tue, May 18, 2010 at 11:51 AM, Colin Paul Adams <[email protected]
> wrote:
> >>>>> "Aditya" == aditya siram <[email protected]> writes:
>
> Aditya> Haskell is considered by many as an inflexible language [1]
>
> Aditya> [1]
> Aditya>
> http://therighttool.hammerprinciple.com/statements/this-language-has-a-very-rigid-idea-of-how-things-
>
> Maybe, but that reference describes it as rigid, not inflexible.
> --
> Colin Adams
> Preston Lancashire
> () ascii ribbon campaign - against html e-mail
> /\ www.asciiribbon.org - against proprietary attachments
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
--
Flatliner ICT Service,
Email: [email protected],
Tel: +31727851429
Fax: +31848363080
Skype: edgar.klerks
Website: flatlinerict.nl
Adres: Koelmalaan 258,
1813JD, Alkmaar
Nederland
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100518/0c9de73a/attachment.html
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 23, Issue 27
*****************************************