Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Ivan Lazar Miljenovic
On 25 June 2012 12:50, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  There was another mail, but the subject might be confusing. So I write this one. The code is here: http://hpaste.org/70414  If I understand correct, generally, I could use 'type' to do alias to save the

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Magicloud Magiclouds
Here is the code, I joined two modules in one paste. Both of them cannot pass compiling. http://hpaste.org/70418 On Mon, Jun 25, 2012 at 2:16 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 25 June 2012 12:50, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi,  

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Arlen Cuss
Magicloud, Try to reduce the particular problem you're having to the smallest possible example that reproduces the issue. None of us can compile your code, either, because we're missing many of the dependencies, and unfortunately the issue is no easier (for me) to track down with the full

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Ivan Lazar Miljenovic
On 25 June 2012 19:04, Arlen Cuss a...@len.me wrote: Magicloud, Try to reduce the particular problem you're having to the smallest possible example that reproduces the issue. None of us can compile your code, either, because we're missing many of the dependencies, and unfortunately the

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Magicloud Magiclouds
Sorry, I forgot that. Magicloud.Map.mapM sure is a helper I use as lifted Data.Map.map. If I changed the type of the result of start, the Jobs module compiled. But still cannot compile with the other module (which uses start). And the error is on JobArgs. I post the function here, I am not sure

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Magicloud Magiclouds
Interesting, seems like mapM did not effect the problem Let me try more with the first argument of mapM On Mon, Jun 25, 2012 at 5:04 PM, Arlen Cuss a...@len.me wrote: Magicloud, Try to reduce the particular problem you're having to the smallest possible example that reproduces the

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Magicloud Magiclouds
Even more weird, I installed container-0.5.0.0, and now it just compiled! I will dig more of that. Sorry to bother you guys. On Mon, Jun 25, 2012 at 5:53 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Interesting, seems like mapM did not effect the problem Let me try more

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Arlen Cuss
Glad you worked it out! :) Usually isolating the part of concern in a mysterious error will help shed light on the source! Cheers, Arlen On Monday, 25 June 2012 at 8:00 PM, Magicloud Magiclouds wrote: Even more weird, I installed container-0.5.0.0, and now it just compiled! I will dig

Re: [Haskell-cafe] About using type to do type alias.

2012-06-25 Thread Ivan Lazar Miljenovic
On 25 June 2012 20:00, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Even more weird, I installed container-0.5.0.0, and now it just compiled! I will dig more of that. Sorry to bother you guys. Possibly your Magiclouds module was using a different version of containers or

[Haskell-cafe] About using type to do type alias.

2012-06-24 Thread Magicloud Magiclouds
Hi, There was another mail, but the subject might be confusing. So I write this one. The code is here: http://hpaste.org/70414 If I understand correct, generally, I could use 'type' to do alias to save the ugly-long code. Like section 1. This works when I 't [(0, Just x)]'. But, if I wrote

Re: [Haskell-cafe] About the ConstraintKinds extension

2011-10-18 Thread Max Bolingbroke
On 18 October 2011 02:17, bob zhang bobzhang1...@gmail.com wrote:      But I found a problem which I thought would be made better, plz correct me if I am wrong For those who only subscribe to Haskell-Cafe, Bob posted a very similar thread to ghc-users, which I replied to here with a suggestion

[Haskell-cafe] About the ConstraintKinds extension

2011-10-17 Thread bob zhang
Hi cafe, I have played quite a bit with the ConstraintKinds extension, pretty cool. But I found a problem which I thought would be made better, plz correct me if I am wrong take a contrived example, class C B = B a where here B :: * - Constraint, I think this definition

Re: [Haskell-cafe] About Fun with type functions example

2010-11-19 Thread Miguel Mitrofanov
A continuation. You can't know, what type your fromInt n should be, but you're not going to just leave it anyway, you're gonna do some calculations with it, resulting in something of type r. So, your calculation is gonna be of type (forall n. Nat n = n - r). So, if you imagine for a moment

Re: [Haskell-cafe] About Fun with type functions example

2010-11-19 Thread Arnaud Bailly
Thanks a lot for the explanation. Summarizing: You can't calculate an exact type, but you don't care if the type of the continuation is properly set in order to hide the exact type of n? Am I right? Arnaud On Fri, Nov 19, 2010 at 9:24 AM, Miguel Mitrofanov miguelim...@yandex.ru wrote:  A

Re: [Haskell-cafe] About Fun with type functions example

2010-11-19 Thread Daniel Peebles
The obvious way to write the result would be (stealing some syntax made up by ski on #haskell): fromInt :: Int - (exists n. (Nat n) * n) fromInt = ... meaning, at compile time we don't know the type of the result of fromInt, because it depends on a runtime value, but we'll tell you it's _some_

Re: [Haskell-cafe] About Fun with type functions example

2010-11-19 Thread Arnaud Bailly
Yes it helps, although I am no type wizard! Thanks a lot for these insights, it gives me some more ideas. Best regards Arnaud On Fri, Nov 19, 2010 at 5:55 PM, Daniel Peebles pumpkin...@gmail.com wrote: The obvious way to write the result would be (stealing some syntax made up by ski on

[Haskell-cafe] About Fun with type functions example

2010-11-18 Thread Arnaud Bailly
Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: Here is the code: module Naturals where data Zero data Succ a class Nat n where toInt :: n - Int instance Nat Zero where toInt _ = 0

Re: [Haskell-cafe] About Fun with type functions example

2010-11-18 Thread Erik Hesselink
On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where  toInt   _ = 1 +

Re: [Haskell-cafe] About Fun with type functions example

2010-11-18 Thread Arnaud Bailly
Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be interested in the fromInt too. Arnaud On Thu, Nov 18, 2010 at 8:22 PM, Erik Hesselink hessel...@gmail.com wrote: On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to

Re: [Haskell-cafe] About Fun with type functions example

2010-11-18 Thread Daniel Peebles
The best you can do with fromInt is something like Int - (forall n. (Nat n) = n - r) - r, since the type isn't known at compile time. On Thu, Nov 18, 2010 at 2:52 PM, Arnaud Bailly arnaud.oq...@gmail.comwrote: Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be

Re: [Haskell-cafe] About Fun with type functions example

2010-11-18 Thread Arnaud Bailly
Just after hitting the button send, it appeared to me that fromInt was not obvious at all, and probably impossible. Not sure I understand your answer though: What would be the second parameter (forall n . (Nat n) = n - r) - r) ? Thanks Arnaud On Fri, Nov 19, 2010 at 1:07 AM, Daniel Peebles

Re: [Haskell-cafe] About code style ?

2010-02-02 Thread zaxis
thanks for all suggestions. zaxis wrote: For me i like C style instead of layout. For example, func1 a = do -- ... a * 2 -- ... I always write it as: func1 a = do { -- ...; a * 2; -- ...; } However, i donot know how to write pure function using C style.

Re: [Haskell-cafe] About code style ?

2010-02-02 Thread Jinjing Wang
fac n = let { f = foldr (*) 1 [1..n] } in f :D sorry for double reply, need to cc cafe, this is fun. On Tue, Feb 2, 2010 at 4:33 PM, zaxis z_a...@163.com wrote: thanks for all suggestions. zaxis wrote: For me i like C style instead of layout. For example, func1 a = do      -- ...  

RE: [Haskell-cafe] About code style ?

2010-02-02 Thread Bayley, Alistair
From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of zaxis For me i like C style instead of layout. For example, func1 a = do { -- ...; a * 2; -- ...; } The report has all the gory details. The brace+semicolon syntax isn't just

Re: [Haskell-cafe] About code style ?

2010-02-02 Thread zaxis
fac n = let { f = foldr (*) 1 [1..n] } in f VERY interesting :) Jinjing Wang wrote: fac n = let { f = foldr (*) 1 [1..n] } in f :D sorry for double reply, need to cc cafe, this is fun. On Tue, Feb 2, 2010 at 4:33 PM, zaxis z_a...@163.com wrote: thanks for all suggestions.

[Haskell-cafe] About code style ?

2010-02-01 Thread zaxis
For me i like C style instead of layout. For example, func1 a = do -- ... a * 2 -- ... I always write it as: func1 a = do { -- ...; a * 2; -- ...; } However, i donot know how to write pure function using C style. func1 a = { -- ...; a * 2; -- ...; } will not

Re: [Haskell-cafe] About code style ?

2010-02-01 Thread Ivan Lazar Miljenovic
zaxis z_a...@163.com writes: However, i donot know how to write pure function using C style. func1 a = { -- ...; a * 2; -- ...; } You mean imperatively? Short answer: you can't and you shouldn't. Slightly longer answer: you can possibly fudge something together using the Identity

Re: [Haskell-cafe] About code style ?

2010-02-01 Thread Erik de Castro Lopo
zaxis wrote: For me i like C style instead of layout. For example, func1 a = do -- ... a * 2 -- ... I always write it as: func1 a = do { -- ...; a * 2; -- ...; } Honestly, don't do this. When you're coding in Haskell you should write idiomatic Haskell and

Re: [Haskell-cafe] About code style ?

2010-02-01 Thread Miguel Mitrofanov
However, i donot know how to write pure function using C style. func1 a = { -- ...; a * 2; -- ...; } What do you mean by a * 2? If you don't use this value, don't calculate it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] About code style ?

2010-02-01 Thread Gregory Crosswhite
Ditto what everyone else has said. But to clarify what's going on: The braces are used to introduce a list of things, such as monadic actions, data fields, or declarations. For example, consider the following code: f a = let { a_times_2 = a*2; a_times_4 = a*4; } in

Re: [Haskell-cafe] About xmonad

2009-11-16 Thread Deniz Dogan
2009/11/16 zaxis z_a...@163.com: %uname -a Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux %xmonad --version xmonad 0.9 In firefox, the `save as` dialog doesnot appear when i want to choose

Re: [Haskell-cafe] About xmonad

2009-11-16 Thread zaxis
I have subscribed to xmonad maillist but i never received any email ! Deniz Dogan-3 wrote: 2009/11/16 zaxis z_a...@163.com: %uname -a Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux %xmonad

[Haskell-cafe] About xmonad

2009-11-15 Thread zaxis
%uname -a Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux %xmonad --version xmonad 0.9 In firefox, the `save as` dialog doesnot appear when i want to choose picture to save by right clicking the

[Haskell-cafe] About the parse error (possibly incorrect indentation)

2009-09-17 Thread xu zhang
Hi, I am trying to get the function showMinProp to return String, but I always get an error of parse error (possibly incorrect indentation) Who can help with this? any idea? Thank u in advance! data Prop = Var String | Negation Prop | BinOp Op Prop Prop data Op = And | Or | Implies | Equiv

Re: [Haskell-cafe] About the parse error (possibly incorrect indentation)

2009-09-17 Thread Daniel Fischer
Am Freitag 18 September 2009 02:17:22 schrieb xu zhang: showMinProp :: Int - Prop - String showMinProp preNo (BinOp op p q) =        case op of          And - let a = 4          Or  - let a = 3          Implies - let a = 2          Equiv   - let a = 1        if (a preNo)          then

Re: [Haskell-cafe] About the parse error (possibly incorrect indentation)

2009-09-17 Thread Brandon S. Allbery KF8NH
On Sep 17, 2009, at 20:17 , xu zhang wrote: case op of And - let a = 4 Or - let a = 3 Implies - let a = 2 Equiv - let a = 1 let isn't an assignment command, it's a scoping command. That is, let a = 3 in ... is equivalent to something like {

[Haskell-cafe] About the import module

2009-08-05 Thread xu zhang
Hi there, If I import a module and do not explicitly point out the entities I have imported. And I want the ghc to point out the entities automatically. Is there any method to do this? any methods to have the ghc point out the entities I import and export? Because there are so many files and I

Re: [Haskell-cafe] About the import module

2009-08-05 Thread andy morris
2009/8/5 xu zhang douy...@gmail.com: Hi there, If I import a module and do not explicitly point out the entities I have imported. And I want the ghc to point out the entities automatically. Is there any method to do this? any methods to have the ghc point out the entities I import and

Re: [Haskell-cafe] About the return type

2009-07-11 Thread Brent Yorgey
On Thu, Jul 09, 2009 at 10:57:19AM -0400, xu zhang wrote: I have trouble in returning a list of Figures. I want return a type of m (Maybe [Figure IO]), but the type of dv_findFigure is :: a - Point - s (Maybe (Figure s)). How can change the code below to get a s (Maybe [Figure s])? Thank you

[Haskell-cafe] About return type

2009-07-09 Thread ZhangXu
_ Messenger安全保护中心,免费修复系统漏洞,保护Messenger安全! http://im.live.cn/safe/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] About the return type

2009-07-09 Thread xu zhang
I have trouble in returning a list of Figures. I want return a type of m (Maybe [Figure IO]), but the type of dv_findFigure is :: a - Point - s (Maybe (Figure s)). How can change the code below to get a s (Maybe [Figure s])? Thank you in advance! dv_findFigure :: a - Point - s (Maybe (Figures))

Re: [Haskell-cafe] About the Monad Transformers

2009-06-18 Thread Brandon S. Allbery KF8NH
On Jun 17, 2009, at 11:54 , .shawn wrote: mapTreeM action (Leaf a) = do lift (putStrLn (Leaf ++ show a)) b - action a return (Leaf b) mapTreeM :: (MonadTrans t, Monad (t IO), Show a) = (a - t IO a1) - Tree a - t IO (Tree a1) Why does the type signature of mapTreeM look like

[Haskell-cafe] About the Monad Transformers

2009-06-17 Thread .shawn
On page 141 of Yet another Haskell Tutorial (9.7 Monad Transformers) mapTreeM action (Leaf a) = do lift (putStrLn (Leaf ++ show a)) b - action a return (Leaf b) mapTreeM :: (MonadTrans t, Monad (t IO), Show a) = (a - t IO a1) - Tree a - t IO (Tree a1) Why does the type signature

Re: [Haskell-cafe] About the Monad Transformers

2009-06-17 Thread Miguel Mitrofanov
On 17 Jun 2009, at 19:54, .shawn wrote: Why does the type signature of mapTreeM look like this? Why not? I can't think of any other possibility. And what does it mean by The lift tell us that we're going to be executing a command in an enclosed monad. In this case the enclosed monad is

Re: [Haskell-cafe] About the Monad Transformers

2009-06-17 Thread Neil Brown
.shawn wrote: On page 141 of Yet another Haskell Tutorial (9.7 Monad Transformers) mapTreeM action (Leaf a) = do lift (putStrLn (Leaf ++ show a)) b - action a return (Leaf b) mapTreeM :: (MonadTrans t, Monad (t IO), Show a) = (a - t IO a1) - Tree a - t IO (Tree a1) Why does the type

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Ketil Malde
张旭 stircrazyn...@hotmail.com writes: Hi, I am really new to haskell. I am reading A gentle instruction to haskell now. And I just cannot understand the chapter below. Is there anybody who can gives me some hints about why the pattern matching for client is so early? How does the pattern

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Petr Pudlak
Hi Ryan, thanks for a nice and thorough explanation. I had trouble understanding the section of the tutorial as well. Maybe it would deserve to rewrite to something a bit simpler? Anyhow, I'd like to ask: Is there a reason for which pattern matching for single-constructor data types isn't lazy by

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Max Bolingbroke
2009/5/28 Petr Pudlak d...@pudlak.name: Hi Ryan, thanks for a nice and thorough explanation. I had trouble understanding the section of the tutorial as well. Maybe it would deserve to rewrite to something a bit simpler? Anyhow, I'd like to ask: Is there a reason for which pattern matching for

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Ryan Ingram
The main change I would make is to rename the arguments to client/server; they overload the same names (reqs/resps) as the top level declarations above, so it's very easy to get confused while reading it. Partially, I think this is just a hard concept to understand; struggling to figure it out

Re: [Haskell-cafe] About the lazy pattern

2009-05-27 Thread Bulat Ziganshin
Hello 张旭, Wednesday, May 27, 2009, 11:51:34 PM, you wrote: Hi, I am really new to haskell. I am reading A gentle instruction to haskell now. And I just cannot understand the chapter below. Is there anybody who can gives me some hints about why the pattern matching for client is so early?

Re: [Haskell-cafe] About the lazy pattern

2009-05-27 Thread Ryan Ingram
Hi nemo. I had a lot of trouble with that section of the tutorial as well, and I believe that once you get it, a lot of Haskell becomes a lot simpler. The way I eventually figured it out is using this idealized execution model for Haskell: you just work by rewriting the left side of a function

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-04-04 Thread Thomas Hartman
takeListSt' = evalState . foldr k (return []) . map (State . splitAt) where k m m'= cutNull $ do x-m; xs-m'; return (x:xs) cutNull m = do s-get; if null s then return [] else m Not only is ths not that elegant anymore, I think it *still* has a bug, stack overflow against

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-04-04 Thread Claus Reinke
takeListSt' = evalState . foldr k (return []) . map (State . splitAt) where k m m'= cutNull $ do x-m; xs-m'; return (x:xs) cutNull m = do s-get; if null s then return [] else m |Not only is ths not that elegant anymore, As I was saying, sequence/mapM with early cutout is

[Haskell-cafe] about import alias

2009-04-04 Thread Manlio Perillo
Hi. Haskell 98 allows import alias: import qualified VeryLongModuleName as C however it does not allow aliasing for imported names import NormalModule (veryLongFunctionName as C) what is the rational? IMHO this can be very useful in some cases. Thanks Manlio

Re: [Haskell-cafe] about import alias

2009-04-04 Thread Marcin Kosiba
On Saturday 04 April 2009, Manlio Perillo wrote: Hi. Haskell 98 allows import alias: import qualified VeryLongModuleName as C however it does not allow aliasing for imported names import NormalModule (veryLongFunctionName as C) what is the rational? IMHO this can be very

Re: [Haskell-cafe] about import alias

2009-04-04 Thread Daniel Fischer
Am Samstag 04 April 2009 17:33:55 schrieb Manlio Perillo: Hi. Haskell 98 allows import alias: import qualified VeryLongModuleName as C however it does not allow aliasing for imported names import NormalModule (veryLongFunctionName as C) what is the rational? IMHO this can be

Re: [Haskell-cafe] about import alias

2009-04-04 Thread Neil Mitchell
Hi You can always do {-# INLINE short #-} short = C.veryLongFunctionNameThatIReallyDoNotWantToTypeOutEveryTimeIUseIt The INLINE pragma is not necessary, if an optimising compiler fails to inline that then it's not very good. However, you might want to consider the (evil) monomorphism

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-04-04 Thread Thomas Hartman
Thanks Claus, Indeed the problem was that I was using the Strict state monad, with lazy state it does the right thing when run through testP. I will try and get back to this thread if I manage the derivation which proves (or at least supports) that the two versions are equivalent. 2009/4/4

Re: [Haskell-cafe] about the Godel Numbering for untyped lambda calculus

2009-03-31 Thread John Tromp
I am reading the book The lambda calculus: Its syntax and Semantics in the chapter about Godel Numbering but I am confused in some points. We know for Church Numerals, we have Cn = \fx.f^n(x) for some n=0, i.e. C0= \fx.x and C 1 = \fx.fx. From the above definition, I could guess the

Re: [Haskell-cafe] about the Godel Numbering for untyped lambda calculus

2009-03-31 Thread wren ng thornton
John Tromp wrote: I am reading the book The lambda calculus: Its syntax and Semantics in the chapter about Godel Numbering but I am confused in some points. We know for Church Numerals, we have Cn = \fx.f^n(x) for some n=0, i.e. C0= \fx.x and C 1 = \fx.fx. From the above definition, I could

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-27 Thread Claus Reinke
Continuing our adventures into stylistic and semantic differences:-) Can you write this analysis on the wiki? Hmm, we tried that in the past, and I haven't seen any indication that people search for those things, let alone find them (one particular example I recalled I still haven't been able

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-26 Thread Colin Adams
2009/3/25 wren ng thornton w...@freegeek.org:  Most of the documentation is in research papers, and a normal  programmer don't want to read these papers. Yes, and no. There is quite a bit of documentation in research papers, and mainstream programmers don't read research. However, this is a

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-26 Thread Loup Vaillant
2009/3/26 Thomas Hartman tphya...@gmail.com: Beginner list processing code can and often does go awry when presented with infinite lists. I didn't mean code that a beginner would write, I mean code that would be easy to understand for a beginner to read For that, in this particular example,

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-26 Thread Claus Reinke
Continuing our adventures into stylistic and semantic differences:-) Comparing the 'State' and explicit recursion versions takeListSt = evalState . mapM (State . splitAt) -- ..with a derivation leading to.. takeListSt []s = [] takeListSt (h:t) s = x : takeListSt t s'

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-26 Thread Lutz Donnerhacke
* Claus Reinke wrote: Continuing our adventures into stylistic and semantic differences:-) It's good practice to keep a simple minded version of the code and using quickcheck to try to find differences between the optimized and trivial version. It's good practice to even check, that the

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-26 Thread Manlio Perillo
Claus Reinke ha scritto: Continuing our adventures into stylistic and semantic differences:-) Can you write this analysis on the wiki? Thanks! Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Thomas Hartman
I wonder if JHC or some other compiler might work better with these examples? Are you saying that different compilers might give different answers? Yikes! Too clever indeed! 2009/3/26 rocon...@theorem.ca: On Wed, 25 Mar 2009, Thomas Hartman wrote: With the state version, there's a lot of

mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread roconnor
On Wed, 25 Mar 2009, Thomas Hartman wrote: With the state version, there's a lot of behind-the-scenes magic, and as we've seen, things can go wrong. Also, the issue isn't infinite lists, but lists that are longer than the sum of the partitions provided. The state monad partition version goes

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Jonathan Cast
On Thu, 2009-03-26 at 12:29 -0700, Thomas Hartman wrote: I wonder if JHC or some other compiler might work better with these examples? Are you saying that different compilers might give different answers? Yikes! Too clever indeed! No, they might produce code with different

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Thomas Hartman
Well, that's reassuring. The reason I asked is that the testp function didn't just show poor performance. The state monad implementation actually gave a different answer -- nonterminating, where the pattern matching solution terminated. 2009/3/26 Jonathan Cast jonathancc...@fastmail.fm: On Thu,

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-26 Thread wren ng thornton
Colin Adams wrote: 2009/3/25 wren ng thornton w...@freegeek.org: Most of the documentation is in research papers, and a normal programmer don't want to read these papers. Yes, and no. There is quite a bit of documentation in research papers, and mainstream programmers don't read

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Colin Adams
2009/3/24 Jonathan Cast jonathancc...@fastmail.fm: On Tue, 2009-03-24 at 22:33 +0300, Eugene Kirpichov wrote: Pretty cool once you know what the function does, but I must admit I wouldn't immediately guess the purpose of the function when written in this way. I wouldn't immediately guess the

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
What about import Data.List partAt n xs =  let (beg,end) = splitAt n xs  in beg : ( case end of               [] - []               xs - partAt n xs) t = partAt 3 [1..10] It's tail recursive (I think!) and should be pretty easy to understand even for a beginner, no? 2009/3/24 Manlio Perillo

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
sorry, wrong function. should be partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : ( case end of [] - [] xs - partitions parts xs) t = partitions [1,2,3] [1..10] which is not quite as nice, I admit. 2009/3/25 Thomas

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Manlio Perillo
wren ng thornton ha scritto: Manlio Perillo wrote: [...] Following directly from the Rule of Least Power, if you can get away with foreach then that's what you should use. Why? Because the less power the construct has, the fewer corner cases and generalizations a reader of the code needs to

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Claus Reinke
The beauty of functional programming is that there doesn't have to be a conflict between those who prefer explicit and those who prefer implicit recursion. Think of them as different views on the same functions - just as with graphical visualizations, pick the view best suited to your purpose

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Zachary Turner
On Tue, Mar 24, 2009 at 10:32 PM, wren ng thornton w...@freegeek.orgwrote: Both of these conclusions seem quite natural to me, even from before learning Haskell. It seems, therefore, that naturality is not the proper metric to discuss. It's oft overlooked, but the fact is that expressivity

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Gregg Reynolds
2009/3/25 Zachary Turner divisorthe...@gmail.com: On the other hand, -certain- languages are more expressive than others.  As an example, I personally find English far more expressive than both Vietnamese and Japanese, yet English is far more complicated.  Japanese, for Way off topic, but for

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread wren ng thornton
Thomas Hartman wrote: sorry, wrong function. should be partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : ( case end of [] - [] xs - partitions parts xs) It's not tail recursive, FWIW. The recursive expression has (:) as

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Dan Weston
So to be clear with the terminology: inductive = good consumer? coinductive = good producer? So fusion should be possible (automatically? or do I need a GHC rule?) with inductive . coinductive Or have I bungled it? Dan wren ng thornton wrote: Thomas Hartman wrote: sorry, wrong

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Are you saying there's a problem with this implementation? It's the Yes, there is actually a problem with this implementation. import Data.List import Control.Monad.State import Debug.Trace.Helpers partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : (

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Dan Weston
However, there is something to be said for code that just looks like a duck and quacks like a duck. It's less likely to surprise you. So... I insist... Easy for a beginner to read == better! All you have said is that one building a skyscraper will need scaffolding, blueprints, and a good

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Jonathan Cast
On Wed, 2009-03-25 at 12:48 -0700, Dan Weston wrote: However, there is something to be said for code that just looks like a duck and quacks like a duck. It's less likely to surprise you. So... I insist... Easy for a beginner to read == better! All you have said is that one building a

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Oh, and incidentally, if you change to Control.Monad.State.Strict *Main testP partitionsTooFrickinClever testP partitionsTooFrickinClever^J*** Exception: stack overflow Don't get me wrong -- I have learned a lot from this thread, and I think it would be really cool if there was a way to do this

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Since this thread is ostensibly about haskell style, it should also be about haskell style *today*. As I think Yitz noted earlier, this is a moving target. Adoption of haskell by the masses -- moving. Skill of haskell hordes -- moving. Abstractions available as part of idiomatic haskell, and

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Not only is your simpler function easier to read, it is also more correct. partitionsHubris xs ns = zipWith take ns . init $ scanl (flip drop) xs ns partitionsBeginner :: [Int] - [a] - [[a]] partitionsBeginner [] _ = [] partitionsBeginner _ [] = [] partitionsBeginner (n : ns)

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
s/Pattern matching is awesome language feature. use it! /Pattern matching is awesome language feature. Don't be ashamed to use it! / :) 2009/3/25 Thomas Hartman tphya...@gmail.com: Not only is your simpler function easier to read, it is also more correct. partitionsHubris xs ns = zipWith

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread wren ng thornton
Manlio Perillo wrote: The main problem, here, is that: - recursion and pattern matching are explained in every tutorial about functional programming and Haskell. This is the reason why I find them more natural. - high level, Haskell specific, abstractions, are *not* explained in normal

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread wren ng thornton
Dan Weston wrote: So to be clear with the terminology: inductive = good consumer? coinductive = good producer? So fusion should be possible (automatically? or do I need a GHC rule?) with inductive . coinductive Or have I bungled it? Not quite. Induction means starting from base cases

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Dan Piponi
On Wed, Mar 25, 2009 at 12:44 PM, Thomas Hartman tphya...@gmail.com wrote: Are you saying there's a problem with this implementation? It's the Yes, there is actually a problem with this implementation. However, there is something to be said for code that just looks like a duck and quacks

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Beginner list processing code can and often does go awry when presented with infinite lists. I didn't mean code that a beginner would write, I mean code that would be easy to understand for a beginner to read -- that is, explicit pattern matching, explicit recursion, no gratuitous use of state

[Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Manlio Perillo
Hi. In these days I'm discussing with some friends, that mainly use Python as programming language, but know well other languages like Scheme, Prolog, C, and so. These friends are very interested in Haskell, but it seems that the main reason why they don't start to seriously learning it, is

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Tim Newsham
These friends are very interested in Haskell, but it seems that the main reason why they don't start to seriously learning it, is that when they start reading some code, they feel the Perl syndrome. That is, code written to be too smart, and that end up being totally illegible by Haskell

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Sjur Gjøstein Karevoll
I know what you're saying, in a way. There is much haskell code that's completely illegible to me. I would say there is a difference between Haskell and Perl though, in that Perl code is too smart aka. clever, while Haskell code is usually simply, well, too smart. This means code written using

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Jake McArthur
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Manlio Perillo wrote: | These friends are very interested in Haskell, but it seems that the main | reason why they don't start to seriously learning it, is that when they | start reading some code, they feel the Perl syndrome. | | That is, code

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Miguel Mitrofanov
Well, I'd say that there is something close to the Perl syndrome, in some sense. After all, code IS usually very smart. The difference is that in Perl all smartness is about knowing how the computer works, or how the interpreter works. In Haskell, instead, the smartness is about knowing -

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Manlio Perillo
Tim Newsham ha scritto: These friends are very interested in Haskell, but it seems that the main reason why they don't start to seriously learning it, is that when they start reading some code, they feel the Perl syndrome. That is, code written to be too smart, and that end up being totally

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Manlio Perillo
Jake McArthur ha scritto: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Manlio Perillo wrote: | These friends are very interested in Haskell, but it seems that the main | reason why they don't start to seriously learning it, is that when they | start reading some code, they feel the Perl

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Jonathan Cast
On Tue, 2009-03-24 at 19:42 +0100, Manlio Perillo wrote: Tim Newsham ha scritto: These friends are very interested in Haskell, but it seems that the main reason why they don't start to seriously learning it, is that when they start reading some code, they feel the Perl syndrome. That

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Jake McArthur
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Manlio Perillo wrote: | This is right. | The problem is that often (IMHO) a function definition can be rewritten | so that it is much more readable. | | As an example, with the takeList function I posted. I looked at it, found nothing wrong with the

  1   2   3   >