Re: [Haskell] recursion patterns?

2013-05-21 Thread David Virebayre
2013/5/15 7stud 7s...@excite.com The first solution works for infinite lists and the second one does not. I don't see how that's possible. Both traversals seem to be limited by n, and therefore they do not have to touch the end of the list. In any case, it would seem to me that the *first*

[Haskell] recursion patterns?

2013-05-15 Thread 7stud
Well, my question does not meet the standards for a question at stackoverflow: (I am a haskell beginner) This example is from LYAH: import System.Random finiteRandoms :: (RandomGen g, Random a, Num n) = n - g - ([a], g) finiteRandoms 0 gen = ([], gen) finiteRandoms n gen =

Re: [Haskell] recursion patterns?

2013-05-15 Thread Henning Thielemann
On Wed, 15 May 2013, 7stud wrote: Well, my question does not meet the standards for a question at stackoverflow: (I am a haskell beginner) Then you might want to post your question to haskell-beginners mailing list. Is one solution more efficient than the other? I believe my solution is

Re: [Haskell] recursion patterns?

2013-05-15 Thread 7stud
Is one solution more efficient than the other? I believe my solution is tail recursive, but it's my understanding that compilers can now optimize just about anything into tail recursion. The first solution works for infinite lists and the second one does not. I don't see how that's

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread dm-list-haskell-cafe
At Fri, 1 Jul 2011 09:39:32 +0400, Eugene Kirpichov wrote: Hi, I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a problem arises: How to represent large but finite streams and functions that process them, returning other streams or some kinds of aggregate

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Heinrich Apfelmus
Eugene Kirpichov wrote: I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a problem arises: How to represent large but finite streams and functions that process them, returning other streams or some kinds of aggregate values? Examples: * Adjacent differences of

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Plain old lazy lists do not allow me to combine multiple concurrent computations, e.g. I cannot define average from sum and length. 2011/7/1 Heinrich Apfelmus apfel...@quantentunnel.de: Eugene Kirpichov wrote: I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Malcolm Wallace
Sure you can. runningAverage :: Int - [Double] - [Double] runningAverage n xs = let chunk = take n xs in (sum chunk / length chunk) : runningAverage (tail xs) Lazy lists are absolutely ideal for this purpose. Regards, Malcolm On 1 Jul 2011, at 07:33, Eugene Kirpichov

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
I meant the average of the whole list - given a sumS and lengthS (S for Stream), write meanS as something like liftS2 (/) sumS lengthS. Or is that possible with lazy lists too? (looks like arrows actually - which arrow is appropriate here?) 2011/7/1 Malcolm Wallace malcolm.wall...@me.com: Sure

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Alexey Khudyakov
On Fri, Jul 1, 2011 at 12:21 PM, Eugene Kirpichov ekirpic...@gmail.com wrote: I meant the average of the whole list - given a sumS and lengthS (S for Stream), write meanS as something like liftS2 (/) sumS lengthS. Or is that possible with lazy lists too? Sure you can. Sum, length and mean

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Alexey, your definition of mean does not look like liftS2 (/) sum length - you have to manually fuse these computations. I'm asking for a formalism that does this fusion automatically (and guaranteedly). 2011/7/1 Alexey Khudyakov alexey.sklad...@gmail.com: On Fri, Jul 1, 2011 at 12:21 PM,

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Alexey Khudyakov
On Fri, Jul 1, 2011 at 12:54 PM, Eugene Kirpichov ekirpic...@gmail.com wrote: Alexey, your definition of mean does not look like liftS2 (/) sum length - you have to manually fuse these computations. Well it was fused for numerical stability I'm asking for a formalism that does this fusion

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Heinrich Apfelmus
Eugene Kirpichov wrote: Plain old lazy lists do not allow me to combine multiple concurrent computations, e.g. I cannot define average from sum and length. I meant the average of the whole list - given a sumS and lengthS (S for Stream), write meanS as something like liftS2 (/) sumS lengthS.

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Thanks but I'm afraid that's still not quite what I'm looking for; guess I'll have to define my desire by my implementation - so once it's ready I'll show the result to cafe :) 2011/7/1 Alexey Khudyakov alexey.sklad...@gmail.com: On Fri, Jul 1, 2011 at 12:54 PM, Eugene Kirpichov

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread John Lato
From: Eugene Kirpichov ekirpic...@gmail.com Subject: [Haskell-cafe] Patterns for processing large but finite streams To: Haskell Cafe haskell-cafe@haskell.org Message-ID: banlktikdsvq2wv4wjr+qmuvksoav0kt...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Hi, I'm

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread John Lato
After the list discussion, I'm surprised nobody mentioned Max Rabkin/Conal Elliott's blog posts on folds and zips. http://squing.blogspot.com/2008/11/beautiful-folding.html http://conal.net/blog/posts/enhancing-a-zip/ They develop a formalism for zipping functions on lists. Iteratee's `zip` set

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Hi, You're right, reifying stream processing functions seems indeed the way to go - and that looks even more like arrows :) I thought of something like this: data SP i o = Yield [o] (Maybe (Maybe i - SP i o)) Scalar functions like sum and length are just SP's that return a single item in the

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Ketil Malde
Eugene Kirpichov ekirpic...@gmail.com writes: 2011/7/1 Heinrich Apfelmus apfel...@quantentunnel.de: Eugene Kirpichov wrote: I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a problem arises: Plain old lazy lists? Heretic! :-) I generally have written a

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Erik Hesselink
This sound exactly like what attribute grammars, like the system developed at Utrecht University [1], are useful for. Erik [1] http://www.cs.uu.nl/wiki/HUT/AttributeGrammarSystem On Fri, Jul 1, 2011 at 10:54, Eugene Kirpichov ekirpic...@gmail.com wrote: Alexey, your definition of mean does not

[Haskell-cafe] Patterns for processing large but finite streams

2011-06-30 Thread Eugene Kirpichov
Hi, I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a problem arises: How to represent large but finite streams and functions that process them, returning other streams or some kinds of aggregate values? Examples: * Adjacent differences of a stream of numbers *

[Haskell-cafe] Patterns overlapped?

2008-01-13 Thread Fernando Rodriguez
Hi, When I compile this code, ghc complains about some overlapped patterns in function depth. What on Earth is ghc talking about? O:-) data BinTree a = EmptyTree | NodeBT a (BinTree a) (BinTree a) deriving Show emptyBT = EmptyTree depth emptyBT = 0

Re: [Haskell-cafe] Patterns overlapped?

2008-01-13 Thread Brandon S. Allbery KF8NH
On Jan 13, 2008, at 13:59 , Fernando Rodriguez wrote: When I compile this code, ghc complains about some overlapped patterns in function depth. What on Earth is ghc talking about? O:-) emptyBT = EmptyTree depth emptyBT = 0 depth (NodeBT _ left right) = max (1 + depth left) (1 + depth

Re: [Haskell-cafe] Patterns overlapped?

2008-01-13 Thread jerzy . karczmarczuk
Fernando Rodriguez writes: What on Earth is ghc talking about? O:-) (overlapping paterns) emptyBT = EmptyTree depth emptyBT = 0 depth (NodeBT _ left right) = max (1 + depth left) (1 + depth right) GHC is always right... Your first clause is GENERIC,

RE: [Haskell] Bang patterns and declaration order

2007-11-19 Thread Simon Peyton-Jones
: 18 November 2007 22:47 To: Derek Elkins Cc: Haskell users Subject: Re: [Haskell] Bang patterns and declaration order I totally agree with Derek. Which exception you get can vary with compiler version, compiler flags, time of day, phase of the moon, ... It will be one in a set of exceptions

[Haskell] Bang patterns and declaration order

2007-11-18 Thread Iavor Diatchki
Hello, I was playing around with bang patterns and I noticed that when combined with asynchronous exceptions they can lead to programs where the order of the declarations in a binding group is important! Here is an example: import Control.Exception import Prelude hiding (catch) main =

Re: [Haskell] Bang patterns and declaration order

2007-11-18 Thread Felipe Lessa
On Nov 18, 2007 6:11 PM, Iavor Diatchki [EMAIL PROTECTED] wrote: I was playing around with bang patterns and I noticed that when combined with asynchronous exceptions they can lead to programs where the order of the declarations in a binding group is important! I think that's why they may be

Re: [Haskell] Bang patterns and declaration order

2007-11-18 Thread Derek Elkins
On Sun, 2007-11-18 at 12:11 -0800, Iavor Diatchki wrote: Hello, I was playing around with bang patterns and I noticed that when combined with asynchronous exceptions they can lead to programs where the order of the declarations in a binding group is important! Here is an example:

Re: [Haskell] Bang patterns and declaration order

2007-11-18 Thread Lennart Augustsson
I totally agree with Derek. Which exception you get can vary with compiler version, compiler flags, time of day, phase of the moon, ... It will be one in a set of exceptions, but you don't know which one. -- Lennart On Nov 18, 2007 8:34 PM, Derek Elkins [EMAIL PROTECTED] wrote: On Sun,

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-08-01 Thread ChrisK
Discussion continues below quoted text... Stefan O'Rear wrote: On Tue, Jul 31, 2007 at 03:31:54PM -0700, David Roundy wrote: On Mon, Jul 30, 2007 at 11:47:46AM +0100, Jon Fairbairn wrote: ChrisK [EMAIL PROTECTED] writes: And the readability is destroyed because you cannot do any type

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-08-01 Thread Jon Fairbairn
David Roundy [EMAIL PROTECTED] writes: On Mon, Jul 30, 2007 at 11:47:46AM +0100, Jon Fairbairn wrote: [snippage] This is all very horrid, but as far as I can tell what I was proposing wouldn't lead to such a mess, except possibly via defaulting, which, as the least important aspect of

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-07-31 Thread David Roundy
On Mon, Jul 30, 2007 at 11:47:46AM +0100, Jon Fairbairn wrote: ChrisK [EMAIL PROTECTED] writes: And the readability is destroyed because you cannot do any type inference in your head. If you see { Matrix m = ; Matrix x = m * y; ...; } Then you know very little

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-07-31 Thread David Roundy
On Tue, Jul 31, 2007 at 04:04:17PM -0700, Stefan O'Rear wrote: On Tue, Jul 31, 2007 at 03:31:54PM -0700, David Roundy wrote: On Mon, Jul 30, 2007 at 11:47:46AM +0100, Jon Fairbairn wrote: ChrisK [EMAIL PROTECTED] writes: And the readability is destroyed because you cannot do any type

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-30 Thread Dan Licata
With the functional dependency, you can't work with the view datatypes at all. Once you write type Typ data TypView = Unit | Arrow Typ Typ instance View Typ TypView where view = ... you're no longer allowed to take apart a TypView at all! E.g. you can't write outUnit :: TypView - Bool

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Requestforfeedback

2007-07-30 Thread Dan Licata
On Jul30, Claus Reinke wrote: one could turn that promise into a type-checked guarantee by using explicit sum types (and thus structural rather than name-based typing), but that gets awkward in plain haskell. I don't think the choice of whether you label your variants with names or with

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-07-30 Thread Jon Fairbairn
ChrisK [EMAIL PROTECTED] writes: And the readability is destroyed because you cannot do any type inference in your head. If you see { Matrix m = ; Matrix x = m * y; ...; } Then you know very little about the possible types of y since can only conclude that: [snippage] This

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-30 Thread Stefan O'Rear
On Mon, Jul 30, 2007 at 05:31:40AM -0400, Dan Licata wrote: With the functional dependency, you can't work with the view datatypes at all. Once you write type Typ data TypView = Unit | Arrow Typ Typ instance View Typ TypView where view = ... you're no longer allowed to take apart a

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-07-29 Thread ChrisK
And the readability is destroyed because you cannot do any type inference in your head. If you see { Matrix m = ; Matrix x = m * y; ...; } Then you know very little about the possible types of y since can only conclude that: Matrix can be multiplied by one or more types 'sometype'

[Haskell] Irrefutable patterns allowing mutually dependent functions.

2007-07-27 Thread Michael Speer
Some time ago I wrote to this list linking to a regular expression engine I was writing in order to learn the Haskell programming language. I had noted the ability to send a single functions output into it as the its input and had tried using this property of the language in a rather winding way

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-27 Thread Jon Fairbairn
ChrisK [EMAIL PROTECTED] writes: Jon Fairbairn wrote: I currently only get f :: [t] - something, so if I later discover that I need to change the input representation to be more efficient than lists, I have to rewrite f. Wouldn't it be so much nicer if I could simply add a declaration

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-27 Thread Dan Licata
On Jul26, Stefan O'Rear wrote: So, this syntax affects a lot of code, existing or otherwise, that doesn't use view patterns, which is something we're trying to avoid. Eh? I *think* the typing rules are the same for the no-view case. If the auto-deriving hack isn't implemented, you only

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-27 Thread Dan Licata
On Jul26, apfelmus wrote: Yes, the types of the patterns don't unify. But each one is a specialization of the argument type. Note that the type signature is bar :: (forall a . ViewInt a = a) - String which is very different from bar :: forall a . ViewInt a = a - String Without

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-27 Thread Conor McBride
Me: In the dependently typed setting, it's often the case that the with-scrutinee is an expression of interest precisely because it occurs in the *type* of the function being defined. Correspondingly, an Epigram implementation should (and the Agda 2 implementation now does)

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-27 Thread Jonathan Cast
On Friday 27 July 2007, Jon Fairbairn wrote: ChrisK [EMAIL PROTECTED] writes: Jon Fairbairn wrote: I currently only get f :: [t] - something, so if I later discover that I need to change the input representation to be more efficient than lists, I have to rewrite f. Wouldn't it be so

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request forfeedback

2007-07-27 Thread Jacques Carette
Others have already pointed this out, but it is worth saying again: Maybe is not the only monadic effect which makes sense during pattern-matching. Wolfram Kahl and I have explored some of these things as part of the Pattern Matching Calculus, http://sqrl.mcmaster.ca/~kahl/PMC/ [If you want

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-07-27 Thread David Roundy
On Fri, Jul 27, 2007 at 09:02:42AM -0500, Jonathan Cast wrote: On Friday 27 July 2007, Jon Fairbairn wrote: ChrisK [EMAIL PROTECTED] writes: Because this is starting to sound like one of the maddening things about C++. Namely, the automatic implicit casting conversions of classes

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

2007-07-27 Thread Aaron Denney
On 2007-07-27, David Roundy [EMAIL PROTECTED] wrote: The solution is to add explicit to the constructor for all single-argument constructors (except perhaps occasionally when you actually want explicit construction of objects). The reasoning behind this, of course, is to allow nice

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-26 Thread Barney Hilken
I think you should add the form: (function - pattern) @ pattern as well. The reason you don't need general 'pattern @ pattern' with normal patterns is that, if anything is going to match, the two patterns must have the same outermost constructor, so you can push the @ inside. This doesn't

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-26 Thread ChrisK
Jon Fairbairn wrote: I currently only get f :: [t] - something, so if I later discover that I need to change the input representation to be more efficient than lists, I have to rewrite f. Wouldn't it be so much nicer if I could simply add a declaration f:: Stream s = s t - something and get

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-26 Thread Dan Licata
that none of these options supports the value input feature; we need new syntax to support non-binding identifiers in patterns! Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-26 Thread apfelmus
Dan Licata wrote: apfelmus wrote: The idea is to introduce a new language extension, namely the ability to pattern match a polymorphic type. For demonstration, let class ViewInt a where view :: Integer - a instance ViewInt [Bool] where view n = ... -- binary representation

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-26 Thread Conor McBride
Hi Dan On 25 Jul 2007, at 15:18, Dan Licata wrote: Hi Conor, [..] Why are you so fatalistic about with in Haskell? I guess I'm just fatalistic, generally. Plausibility is not something I'm especially talented at. Is it harder to implement than it looks? For Haskell, it ought to be

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Dan Licata
Hi everyone, Thanks for all the helpful feedback! It's great to see what people think. Let me just respond to one point at the moment: I think that the signature type Typ unit :: Typ - Maybe () arrow :: Type - Maybe (Typ,Typ) is *wrong* if what you really mean is type Typ

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Claus Reinke
I think that the signature type Typ unit :: Typ - Maybe () arrow :: Type - Maybe (Typ,Typ) is *wrong* if what you really mean is type Typ data TypView = Unit | Arrow Typ Typ view :: Typ - TypView different =/= wrong !-) That is, if what you mean is that every Typ is

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread ajb
G'day all. Quoting Claus Reinke [EMAIL PROTECTED]: different =/= wrong !-) [...] but that is not what you're saying there at all! you're saying that -within view 'view' of Typ- Typ is mapped to either Unit or Arrow, if the mapping is successfull. there can be other views of Typ, and the

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Claus Reinke
The problem, and we've been through this before, is that it's very tempting to use types like Maybe because it's there, when it's better replaced with a custom algebraic data type. i'm sure we have, and others before us. i was just arguing that one is not necessarily better than the other. i'm

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread apfelmus
Jules Bean wrote: Have you tried using pattern guards for views? f s | y : ys - viewl s = | EmptyL - viewl s = Hm, I'd simply use a plain old case-expression here f s = case viewl s of y : ys - ... EmptyL - ... In other words, case-expressions are as powerful as

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Jules Bean
apfelmus wrote: IMHO, the long-time debate about views is not whether they're useful (I think they are!) but which concrete form to choose. Unfortunately, all of the proposals so far are somehow like Dr. Jekyll and Mr. Hyde: one side is nice but the other is rather ugly. In the end, I might end

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Conor McBride
Hi Ok, I'm not quite under my rock yet,,, On 25 Jul 2007, at 10:28, apfelmus wrote: Jules Bean wrote: Have you tried using pattern guards for views? f s | y : ys - viewl s = | EmptyL - viewl s = This is annoying because the intermediate computation gets repeated. I don't

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Benjamin Franksen
apfelmus wrote: Jules Bean wrote: Have you tried using pattern guards for views? f s | y : ys - viewl s = | EmptyL - viewl s = Hm, I'd simply use a plain old case-expression here f s = case viewl s of y : ys - ... EmptyL - ... In other words,

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Dan Licata
[I think we should move the rest of this thread to haskell-cafe, since it's getting long. Note that there have already been some responses on both lists.] Hi Claus, On Jul25, Claus Reinke wrote: I think that the signature type Typ unit :: Typ - Maybe () arrow :: Type - Maybe

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request forfeedback

2007-07-25 Thread Claus Reinke
Hi Dan, No, of course not. All I meant to say is that sometimes you want a total view, and that a total view should be given a type that says as much. The latter says this better than the former. On the other hand, there are lots of circumstances in which you want a partial view, and I think

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Dan Licata
Hi Conor, This is a really good point, especially in the presence of GADTs and type-level functions and so on, which introduce aspects of dependency. Why are you so fatalistic about with in Haskell? Is it harder to implement than it looks? It seems to be roughly in the same category as our view

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread apfelmus
Benjamin Franksen wrote: apfelmus wrote: In other words, case-expressions are as powerful as any view pattern may be in the single-parameter + no-nesting case. This is how I do it, no pattern guards, no view patterns: zip :: Seq a - Seq b - Seq (a,b) zip xs ys = case (viewl xs,viewl ys)

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Jon Fairbairn
Simon Marlow [EMAIL PROTECTED] writes: Dan Licata wrote: Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. At the risk of being a spoil-sport, I have a somewhat negative take on view patterns. Not because I think they're

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Dan Licata
On Jul25, apfelmus wrote: The point is to be able to define both zip and pairs with one and the same operator : . There's actually a quite simple way of doing this. You make the view type polymorphic, but not in the way you did: type Queue elt empty :: Queue elt cons :: elt -

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Jonathan Cast
On Wednesday 25 July 2007, Jon Fairbairn wrote: Simon Marlow [EMAIL PROTECTED] writes: Dan Licata wrote: Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. At the risk of being a spoil-sport, I have a somewhat negative take

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Derek Elkins
On Wed, 2007-07-25 at 14:12 +0200, Benjamin Franksen wrote: Cheers Ben, member of the we-want-real-views-or-nothing-at-all movement ;-) Derek, member of the counter-culture, we-don't-want-real-views-but-nothing-at-all-may-suffice movement. ___

[Haskell-cafe] Re: Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Benjamin Franksen
Dan Licata wrote: On Jul25, apfelmus wrote: The point is to be able to define both zip and pairs with one and the same operator : . There's actually a quite simple way of doing this. You make the view type polymorphic, but not in the way you did: type Queue elt empty :: Queue

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Stefan O'Rear
On Wed, Jul 25, 2007 at 09:35:32PM +0200, apfelmus wrote: Integer = (forall a . ViewInt a = a) can even be done implicitly and for all types. Together with the magic class View, this would give real views. Jón Fairbairn wrote: It's essential to this idea that it doesn't involve

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread apfelmus
Dan Licata wrote: There's actually a quite simple way of doing this. You make the view type polymorphic, but not in the way you did: myzip :: Queue a - Queue b - Queue (a,b) myzip a b = case (view a, view b) of (EmptyL, _) - empty (_, EmptyL) - empty

Re: [Haskell-cafe] Re: Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-25 Thread Dan Licata
On Jul25, Benjamin Franksen wrote: Dan Licata wrote: On Jul25, apfelmus wrote: The point is to be able to define both zip and pairs with one and the same operator : . There's actually a quite simple way of doing this. You make the view type polymorphic, but not in the way you

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-24 Thread Claus Reinke
though I'm extremely dubious about the utility of the Maybe patterns. actually, they are the main thing that interests me about view patterns!-) it connects them to the existing work on first-class patterns (where combinators over Maybe patterns do the matching work, and view patterns

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-24 Thread Manuel Hernandez
Dear Haskellers, why is so difficult to define a function to compute the average of a list of numbers?? Warm regards!!! Man ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-24 Thread Andreas Marth
didn't read the other proposals. Kind regards Andreas - Original Message - From: Dan Licata [EMAIL PROTECTED] To: haskell@haskell.org Sent: Monday, July 23, 2007 11:09 AM Subject: [Haskell] View patterns in GHC: Request for feedback Hi everyone, Simon PJ and I are implementing view

[Haskell-cafe] RE: [Haskell] View patterns in GHC: Request for feedback

2007-07-24 Thread Simon Peyton-Jones
| At the risk of being a spoil-sport, I have a somewhat negative take on | view patterns. Not because I think they're particularly bad, but | because I don't think they're significantly useful enough to warrant | adding to the language, at least if we also have pattern guards. Syntactic sugar is

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-24 Thread apfelmus
Simon Peyton-Jones wrote: Views have been the subject of rather inconclusive debate for a long time, certainly since the inception of Haskell. I'm thinking of pattern views as a way to break the logjam by implementing something that is a reasonable stab, and seeing whether it sticks. I thought

[Haskell] View patterns in GHC: Request for feedback

2007-07-23 Thread Dan Licata
Hi everyone, Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. Our design is described here: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns If you have any comments or suggestions about this design, we'd love to hear them. You

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-23 Thread Stefan O'Rear
On Mon, Jul 23, 2007 at 05:09:01AM -0400, Dan Licata wrote: Hi everyone, Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. Our design is described here: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns If you have any

Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-23 Thread ajb
G'day all. On Mon, Jul 23, 2007 at 05:09:01AM -0400, Dan Licata wrote: Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. Our design is described here: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns I have to agree. Great

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-23 Thread Simon Marlow
Dan Licata wrote: Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. Our design is described here: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns If you have any comments or suggestions about this design, we'd love to hear

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-23 Thread Jon Harrop
On Monday 23 July 2007 16:57:08 Simon Marlow wrote: Dan Licata wrote: Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. Our design is described here: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns If you have any

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

2007-07-23 Thread apfelmus
to have ByteStrings or Data.Sequence pattern matched like ordinary lists and I think that Data.Graph will blossom with proper view patterns. Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo

[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request forfeedback

2007-07-23 Thread Rene de Visser
Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. Our design is described here: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns If you have any comments or suggestions about this design, we'd love to hear them. You can

Re: [Haskell-cafe] Re: [Haskell] View patterns in GHC: Request forfeedback

2007-07-23 Thread Jonathan Cast
On Monday 23 July 2007, Rene de Visser wrote: Simon PJ and I are implementing view patterns, a way of pattern matching against abstract datatypes, in GHC. Our design is described here: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns If you have any comments or suggestions about

[Haskell] lazy patterns versus where-clauses

2007-06-21 Thread Peter Padawitz
Is f(~p(x))=e(x) semantically equivalent to: f(z)=e(x) where p(x)=z? ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell

[Haskell] Software Patterns Blog

2007-04-11 Thread SPBlog
Greetings, I am pleased to broadcast the launch of a new blog called the software pattern blog http://pattern.ijop.org http://pattern.ijop.org/ . This blog belongs to the editors of IJOP, columnists, staff, advisory, editorial and domain expert boards, external reviewers, and to those who have

[Haskell] Or-Patterns

2006-10-26 Thread Lajos Nagy
Whatever happened to the idea of Or-Patterns? http://www.haskell.org/pipermail/glasgow-haskell-users/2000-December/001535.html I find them more than occasionally useful :) Is there some theoretical difficulty or is it just that nobody had the time/will to implement it? Regards, Lajos Nagy

[Haskell] Announce: HaRP (Haskell Regular Patterns) version 0.2

2004-09-01 Thread Niklas Broberg
We have released a new version of HaRP. Major updates are: * A revised syntax. * Regular patterns are now non-greedy by default. More information and downloads can be found at http://www.dtek.chalmers.se/~d00nibro/harp/ /Niklas Broberg

Re: [Haskell] ANNOUNCE: HaRP (Haskell Regular Patterns) version 0.1

2004-05-16 Thread Niklas Broberg
isn't very good after all since it seems to confuse a lot of people. Perhaps variables bound inside regular patterns should always be non-linear... of course that would still be context dependent when compared to normal Haskell patterns, but perhaps still less confusing? Dylan Thurston wrote

Re: [Haskell] ANNOUNCE: HaRP (Haskell Regular Patterns) version 0.1

2004-05-16 Thread Andreas Farre
Dylan Thurston said: By the way, are nested regular expression matches allowed? Something like: foo :: [[Int]] - Int foo [/ _* [/ 5* a 6* /] _* /] = a Yep. ? If so, what is the type of a in foo [/ _* [/ 5* a* /]* _* /] It would be [[Int]] because of the fact that [/ 5* a* /] alone

[Haskell] ANNOUNCE: HaRP (Haskell Regular Patterns) version 0.1

2004-05-15 Thread Niklas Broberg
A wise man once said, release early and release often. We're obviously not very wise... ;) === Announcing HaRP 0.1 === HaRP is a Haskell extension that extends the normal pattern matching facility with the power of regular expressions. This

Re: [Haskell] ANNOUNCE: HaRP (Haskell Regular Patterns) version 0.1

2004-05-15 Thread Dylan Thurston
This looks very interesting! I sometimes wish Haskell had more powerful binding facilities, so that things like this don't need to be extensions to the language. (But I'm not sure exactly what I'm wishing for...) On Sat, May 15, 2004 at 12:08:53PM +, Niklas Broberg wrote: Introducing

Re: [Haskell] ANNOUNCE: HaRP (Haskell Regular Patterns) version 0.1

2004-05-15 Thread Niklas Broberg
all since it seems to confuse a lot of people. Perhaps variables bound inside regular patterns should always be non-linear... of course that would still be context dependent when compared to normal Haskell patterns, but perhaps still less confusing? Anyway, thanks for the interest

Re: [Haskell] ANNOUNCE: HaRP (Haskell Regular Patterns) version 0.1

2004-05-15 Thread Dylan Thurston
patterns should always be non-linear... of course that would still be context dependent when compared to normal Haskell patterns, but perhaps still less confusing? Alternatively, you could forbid the use of simple variables nonlinearly, since there's an alternative way to write it. Or, you could