Re: [Haskell-cafe] Haskell and the Software design process

2010-05-09 Thread wren ng thornton
Rafael Cunha de Almeida wrote: I don't think that safeSecondElement is worse than secondElement. I think it's better for the program to crash right away when you try to do something that doesn't make sense. Getting the secondElement of a list with one or less elements doesn't make sense, so you

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-09 Thread wren ng thornton
Gregory Crosswhite wrote: Yes, but I think that it is also important to distinguish between cases where an error is expected to be able to occur at runtime, and cases where an error could only occur at runtime *if the programmer screwed up*. Well sure, but how can you demonstrate that you (the

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-09 Thread Gregory Crosswhite
On May 9, 2010, at 1:04 AM, wren ng thornton wrote: If you're structuring your code with that invariant, then why aren't you using the correct type? I do try to use the type system as much as possible to enforce constraints. However. it is not always so simple as making sure that a list

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-07 Thread Brandon S. Allbery KF8NH
On May 3, 2010, at 12:14 , Henning Thielemann wrote: Ketil Malde schrieb: Henning Thielemann lemm...@henning-thielemann.de writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Exception.html#v%3Athrow I see. This should be forbidden, at all! :-) Why is this

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-07 Thread Brandon S. Allbery KF8NH
On May 4, 2010, at 12:31 , Gregory Crosswhite wrote: On May 4, 2010, at 5:22 AM, John Lato wrote: Crashing at the point of the error isn't necessarily useful in Haskell due to lazy evaluation. The code will crash when the result of the partial function is evaluated, which may be quite far away

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-05 Thread Adam Vogt
* On Sunday, May 02 2010, Alexander Dunlap wrote: Of course, there are situations where it is really awkward to not use partial functions, basically because you *know* that an invariant is satisfied and there is no sane course of action if it isn't. To take a contrived example: f ys = let xs =

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread John Lato
From: Rafael Cunha de Almeida assina...@kontesti.me Ivan Miljenovic ivan.miljeno...@gmail.com disse: On 3 May 2010 14:17, aditya siram aditya.si...@gmail.com wrote: I'm a little confused about this too. I've seen many functions defined like: f x = (\s - ...) which is a partial function

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread Casey McCann
On Tue, May 4, 2010 at 9:09 AM, Limestraël limestr...@gmail.com wrote: Are there other methods than Maybe or exceptions to handle the errors in Haskell? Is the monad Error(T) useful? I believe the usual Error monad is just (Either e), with Left indicating failure. It's the same idea as Maybe,

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread John Lato
On Tue, May 4, 2010 at 2:09 PM, Limestraël limestr...@gmail.com wrote: 2010/5/4 John Lato jwl...@gmail.com Crashing at the point of the error isn't necessarily useful in Haskell due to lazy evaluation.  The code will crash when the result of the partial function is evaluated, which may be

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread John Lato
On Tue, May 4, 2010 at 5:31 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: Yes, but I think that it is also important to distinguish between cases where an error is expected to be able to occur at runtime, and cases where an error could only occur at runtime *if the programmer

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread Kyle Murphy
This whole thing seems to be touching on something I saw recently and was quite interested in. I found a site talking about static contract checking in Haskell, unfortunately I can't seem to find it now, but this paper (

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread Gregory Crosswhite
I definitely like that idea. :-) Is this similar to the notion of dependent types? Cheers, Greg On May 4, 2010, at 11:21 AM, Kyle Murphy wrote: This whole thing seems to be touching on something I saw recently and was quite interested in. I found a site talking about static contract

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread Casey McCann
On Tue, May 4, 2010 at 2:43 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: I definitely like that idea.  :-)  Is this similar to the notion of dependent types? That's where things tend to wind up eventually, yes. Although, with Haskell as it stands, a great deal of unused information

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread Edward Kmett
The papers are available here: http://gallium.inria.fr/~naxu/pub.html But in general you can say things like the following: (Dana Xu uses a slightly different notation that I can never remember). sorted :: Ord a = [a] - Bool sorted [] = True sorted [x] = True sorted (x:xs) = x head xs

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread aditya siram
This is awesome! GHC-devs , please mainline the CONTRACT pragma. -deech On 5/4/10, Edward Kmett ekm...@gmail.com wrote: The papers are available here: http://gallium.inria.fr/~naxu/pub.html But in general you can say things like the following: (Dana Xu uses a slightly different notation that

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-04 Thread Colin Paul Adams
aditya == aditya siram aditya.si...@gmail.com writes: aditya This is awesome! GHC-devs , please mainline the CONTRACT aditya pragma. I think it needs a LOT more work before it is usable. (I hope I'm wrong, but Dana reckoned it needed about 7 more man-years of work.) Dana sent me a

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread ajb
G'day all. Quoting aditya siram aditya.si...@gmail.com: I'm a little confused about this too. I've seen many functions defined like: f x = (\s - ...) which is a partial function because it returns a function and is the same as: f x s = ... Off the top of my head the State monad makes

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Roman Leshchinskiy
On 03/05/2010, at 06:02, Jaco van Iterson wrote: I was just wondering what methods are best to design/model the software in bigger projects when you are planning to use Haskell. Is there no difference compared to other languages? Are there any Haskell tools? In addition to what Don said,

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Rafael Cunha de Almeida
Ivan Miljenovic ivan.miljeno...@gmail.com disse: On 3 May 2010 14:17, aditya siram aditya.si...@gmail.com wrote: I'm a little confused about this too. I've seen many functions defined like: f x = (\s - ...) which is a partial function because it returns a function and is the same as: f x s =

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Gregory Collins
Don Stewart d...@galois.com writes: Some key points: * Avoid partial functions As an important corollary to this one I would add: never throw exceptions from pure code. They often leak out from catch blocks and ruin your day. G -- Gregory Collins g...@gregorycollins.net

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Henning Thielemann
On Mon, 3 May 2010, Gregory Collins wrote: Don Stewart d...@galois.com writes: Some key points: * Avoid partial functions As an important corollary to this one I would add: never throw exceptions from pure code. They often leak out from catch blocks and ruin your day. It's not

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Gregory Collins
Henning Thielemann lemm...@henning-thielemann.de writes: It's not possible to throw exceptions from pure code. You can only call 'error' and that's another name for 'undefined', i.e. you have a partial (non-total ?) function.

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Ketil Malde
Henning Thielemann lemm...@henning-thielemann.de writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Exception.html#v%3Athrow I see. This should be forbidden, at all! :-) Why is this worse than or different from 'error'? To me it looks like 'error', only with a

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Henning Thielemann
Ketil Malde schrieb: Henning Thielemann lemm...@henning-thielemann.de writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Exception.html#v%3Athrow I see. This should be forbidden, at all! :-) Why is this worse than or different from 'error'? To me it looks

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Gregory Collins
Ketil Malde ke...@malde.org writes: Henning Thielemann lemm...@henning-thielemann.de writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Exception.html#v%3Athrow I see. This should be forbidden, at all! :-) Why is this worse than or different from 'error'?

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-03 Thread Ketil Malde
Gregory Collins g...@gregorycollins.net writes: Henning Thielemann lemm...@henning-thielemann.de writes: http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Exception.html#v%3Athrow I see. This should be forbidden, at all! :-) Why is this worse than or different from

[Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Jaco van Iterson
Hi I was just wondering what methods are best to design/model the software in bigger projects when you are planning to use Haskell. Is there no difference compared to other languages? Are there any Haskell tools? Cheers, Jaco PS. Software design in Haskell didn't give relevant hits. :(

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Don Stewart
jaco.van.iterson: Hi I was just wondering what methods are best to design/model the software in bigger projects when you are planning to use Haskell. Is there no difference compared to other languages? Are there any Haskell tools? I don't believe anyone has written a Programming Haskell

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Bradford Larsen
On Sun, May 2, 2010 at 4:10 PM, Don Stewart d...@galois.com wrote: I don't believe anyone has written a Programming Haskell in the Large book (or any other similar functional language??), but there is lots of experience in this community working on big, long lived code bases. Some key points:

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Don Stewart
brad.larsen: On Sun, May 2, 2010 at 4:10 PM, Don Stewart d...@galois.com wrote: I don't believe anyone has written a Programming Haskell in the Large book (or any other similar functional language??), but there is lots of experience in this community working on big, long lived code bases.

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Edgar Z. Alvarenga
On Sun, 02/May/2010 at 13:10 -0700, Don Stewart wrote: * Avoid partial functions Why? Edgar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Conor McBride
On 3 May 2010, at 02:18, Edgar Z. Alvarenga wrote: On Sun, 02/May/2010 at 13:10 -0700, Don Stewart wrote: * Avoid partial functions Why? Tell you tomorrow. Conor ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Ivan Miljenovic
On 3 May 2010 11:18, Edgar Z. Alvarenga ed...@ymonad.com wrote: On Sun, 02/May/2010 at 13:10 -0700, Don Stewart wrote:     * Avoid partial functions Why? What does head [] do again? -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Bradford Larsen
On Sun, May 2, 2010 at 9:18 PM, Edgar Z. Alvarenga ed...@ymonad.com wrote: On Sun, 02/May/2010 at 13:10 -0700, Don Stewart wrote:     * Avoid partial functions Why? Edgar Ever place you use a partial function, you need to verify that its usage is in fact safe. Otherwise, you risk pattern

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread aditya siram
I'm a little confused about this too. I've seen many functions defined like: f x = (\s - ...) which is a partial function because it returns a function and is the same as: f x s = ... Off the top of my head the State monad makes extensive use if this style. Is this bad? - deech On 5/2/10,

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Ivan Miljenovic
On 3 May 2010 14:17, aditya siram aditya.si...@gmail.com wrote: I'm a little confused about this too. I've seen many functions defined like: f x = (\s - ...) which is a partial function because it returns a function and is the same as: f x s = ... No, that's a partially applied function. A

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread aditya siram
Cool. That makes way more sense. I thought that ghc -Wall picked these up. So at least this problem would go away if warnings were turned on (and heeded) by default. Besides that from my own experience I'd strongly encourage people to use HLint [1] . -deech [1 ]

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Alexander Dunlap
On Sun, May 2, 2010 at 9:24 PM, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: On 3 May 2010 14:17, aditya siram aditya.si...@gmail.com wrote: I'm a little confused about this too. I've seen many functions defined like: f x = (\s - ...) which is a partial function because it returns a

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Ivan Miljenovic
On 3 May 2010 14:35, Alexander Dunlap alexander.dun...@gmail.com wrote: Of course, there are situations where it is really awkward to not use partial functions, basically because you *know* that an invariant is satisfied and there is no sane course of action if it isn't. True, like map head .

Re: [Haskell-cafe] Haskell and the Software design process

2010-05-02 Thread Sebastian Fischer
On May 3, 2010, at 6:35 AM, Alexander Dunlap wrote: Of course, there are situations where it is really awkward to not use partial functions, basically because you *know* that an invariant is satisfied That falls under Don's: Use types to encode the design into a machine checkable form Or