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

Dylan Thurston dpt at exoskeleton.math.harvard.edu
Sat May 15 10:07:16 EDT 2004


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 +0000, Niklas Broberg wrote:
> Introducing regular expressions into the pattern matching facility gives 
> some extra nice features. One is that the regular patterns are "type safe", 
> i.e. they are not encoded in strings. Another is that identifiers can be 
> named and bound inside regular patterns, examples:
> foo [/ _* a /] = ... => a is bound to the last element of the list
> foo [/ a@(/ _ _ /) _* /] = ... => a is bound to the list containing the 
> first two elements
> foo [/ (/ a _ /)* /] = ... => a is bound to the list of the first, third, 
> fifth etc elements of a list of even length

What about

foo [/ (/ 2 (/ a _ /)* 3 /)* /] = a

?  What is the type of a here?  I think it should be [[Int]].

And then which special syntax for implicit binding am I supposed to use?
Is it

foo [/ (/ 2 (/ a@:(/_ _/) _ /)* 3 /)* /] = a

or maybe

foo [/ (/ 2 (/ a@::(/_ _/) _ /)* 3 /)* /] = a

? And what's the type?  [[[Int]]]?

Peace,
	Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell/attachments/20040515/442f9767/attachment.bin


More information about the Haskell mailing list