[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 H

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 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 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 http://www.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 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 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 match fai

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, B

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

2010-05-02 Thread Ivan Miljenovic
On 3 May 2010 14:17, aditya siram 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 partial function is

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 ] http://hackage.haskell.org/packa

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

2010-05-02 Thread aditya siram
I missed the part where you talked about -Wall. Sorry. On 5/3/10, aditya siram wrote: > 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 experien

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 wrote: > On 3 May 2010 14:17, aditya siram 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-02 Thread Ivan Miljenovic
On 3 May 2010 14:35, 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. True, like "map head . group". -- Ivan Lazar

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" O

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

2010-05-02 Thread ajb
G'day all. Quoting 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. I

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 disse: > On 3 May 2010 14:17, aditya siram 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

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

2010-05-03 Thread Limestraël
There are many ways to handle errors in Haskell. The Maybe method is the simplest but it also comes with a little overhead, since you always have to unpack the Maybe a value return, and finally I often end up by doing something like : maybe (error "Unexpected Nothing") id someSafeFunction when you

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

2010-05-03 Thread Gregory Collins
Don Stewart 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 ___

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 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 possible to throw

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

2010-05-03 Thread Gregory Collins
Henning Thielemann 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. http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Exception.html#v%3

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

2010-05-03 Thread Henning Thielemann
Gregory Collins schrieb: > Henning Thielemann 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. > > http://www.haskell.org/ghc/docs/6.12.2/html/libraries/bas

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

2010-05-03 Thread Ketil Malde
Henning Thielemann 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 non-string parameter. -k

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

2010-05-03 Thread Henning Thielemann
Ketil Malde schrieb: > Henning Thielemann 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', onl

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

2010-05-03 Thread Gregory Collins
Ketil Malde writes: > Henning Thielemann 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

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

2010-05-03 Thread Ketil Malde
Gregory Collins writes: >> Henning Thielemann 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',

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

2010-05-04 Thread John Lato
> From: Rafael Cunha de Almeida > > Ivan Miljenovic disse: >> On 3 May 2010 14:17, aditya siram 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: >>>

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

2010-05-04 Thread Limestraël
2010/5/4 John Lato > "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 (in > terms of function calls) from where the programmer would expect. >

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 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, only returning infor

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 wrote: > 2010/5/4 John Lato >> >> "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 (in >> terms o

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

2010-05-04 Thread Gregory Crosswhite
On May 4, 2010, at 5:22 AM, John Lato wrote: > The reason people argue for safeSecondElement over secondElement is > exactly the reason you argue against it. Calling safeSecondElement on > a list with < 2 elements forces the programmer to handle the result > immediately by returning a Maybe, whic

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 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*.  If you struct

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 ( http://research.microsoft.com/en-us/um/people/simonpj/papers/verify/haskellcon

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 che

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 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 is already present outsid

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 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 I can never

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

2010-05-04 Thread Colin Paul Adams
> "aditya" == aditya siram 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 copy of her ghc 6

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 x

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 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 'e

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 awa

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 a