[Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Martin Hofmann
It is pretty clear, that the following is not a valid Haskell pattern:

foo (x:x:xs) = x:xs

My questions is _why_ this is not allowed. IMHO, the semantics should be
clear: The pattern is expected to succeed, iff 'x' is each time bound to
the same term. 

Isn't this allowed, because this would require a strict evaluation of
the 'x' variables?

Thanks,

Martin

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Miguel Mitrofanov

What would you expect

foo [id, \x - x]

to be?

Martin Hofmann wrote on 15.05.2009 12:09:

It is pretty clear, that the following is not a valid Haskell pattern:

foo (x:x:xs) = x:xs

My questions is _why_ this is not allowed. IMHO, the semantics should be
clear: The pattern is expected to succeed, iff 'x' is each time bound to
the same term. 


Isn't this allowed, because this would require a strict evaluation of
the 'x' variables?

Thanks,

Martin

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Janis Voigtlaender

Martin Hofmann wrote:

It is pretty clear, that the following is not a valid Haskell pattern:

foo (x:x:xs) = x:xs

My questions is _why_ this is not allowed. IMHO, the semantics should be
clear: The pattern is expected to succeed, iff 'x' is each time bound to
the same term. 


Isn't this allowed, because this would require a strict evaluation of
the 'x' variables?


One reason is:

What if the list were a list of functions? How would you decide
sameness of lambda-terms? By investigating their in-memory
representations? By trying to prove that they denote the same
mathematical function?

Ciao, Janis.

--
Dr. Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:vo...@tcs.inf.tu-dresden.de


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Sittampalam, Ganesh
Martin Hofmann wrote:
 It is pretty clear, that the following is not a valid Haskell pattern:
 
 foo (x:x:xs) = x:xs
 
 My questions is _why_ this is not allowed. IMHO, the semantics should
 be 
 clear: The pattern is expected to succeed, iff 'x' is each time bound
 to the same term. 

How do you define the same term?

One natural way of compiling it would be to

foo (x:y:xs) | x == y = x:xs

but then pattern matching can introduce Eq constraints which some might
see as a bit odd.

 Isn't this allowed, because this would require a strict evaluation of
 the 'x' variables? 

The translation into == would probably introduce some strictness, for
most implementations of Eq. I don't think this is a huge problem in
itself.

Ganesh

=== 
 Please access the attached hyperlink for an important electronic 
communications disclaimer: 
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
 
=== 
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Salvador Lucas

Dear Martin,

I think that the (practical) reason is avoiding equality checks during 
pattern matching.


For instance, how do you evaluate this:

  foo ((+1):(1+):[])?

Both expressions in the first and second entries of the list are 
semantically equivalent,
but from an operational point of view, you have to ensure the equality 
of two functions

over an infinite domain (of integer numbers).

Best regards,

Salvador.


Martin Hofmann escribió:

It is pretty clear, that the following is not a valid Haskell pattern:

foo (x:x:xs) = x:xs

My questions is _why_ this is not allowed. IMHO, the semantics should be
clear: The pattern is expected to succeed, iff 'x' is each time bound to
the same term. 


Isn't this allowed, because this would require a strict evaluation of
the 'x' variables?

Thanks,

Martin

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
  


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Pretty printing a tree

2009-05-15 Thread wren ng thornton

José Romildo Malaquias wrote:

Hello.

I would like to pretty print a tree in a way that its structure is
easily perceived.

For instance, consider the declarations:

   data Node a = Node a [Node a]

   type Tree a = [ Node a ]

   t = [ Node a [ Node b []
  , Node c [ Node c1 []
 , Node c2 [] ]
  , Node d [ Node d1 [ Node d1a [] ]
 , Node d2 [] ] ] ]

Then the resulting of pretty printing the given tree would be something
like the following:

   a
   |
+-+
|||
bcd
 ||
   +---++---+
   |   ||   |
   c1  c2   d1  d2
|
   d1a


If you're just curious about how one would write such a thing, you can 
look at Data.Trie.Internal.showTrie[1]--- it's horizontal rather than 
vertical, and it doesn't center labels above their children, but it 
should give you a starting idea. Data.Map and Data.IntMap also have 
examples (showTree, showTreeWith) which are a bit simpler.


This is a common homework assignment (because it's a great exercise!) 
though I haven't seen any prepackaged generic solutions. Perhaps we need 
more enterprising students :)



[1] 
http://community.haskell.org/~wren/bytestring-trie/src/Data/Trie/Internal.hs


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Eugene Kirpichov
Why, then, not permit such definitions only for members of Eq?
My thoughts:
 - because it will break an important invariant indicated by Martin,
namely the one that says that pattern variables are not forced
 - it will make efficient compilation of pattern matching much harder
 - it will make the termination behavior of pattern matching dependent
not only on the term being matched, but also on how Eq is implemented
for that type
 - it will make the very rules of evaluation for pattern matching much
more complex, fragile and hard to understand: in what order should the
equated parts be evaluated? That influences termination behavior, so
it is important. In what order should equality comparisons be
performed in
f (Node a (Leaf b a) (Node a))) = b
?


2009/5/15 Salvador Lucas slu...@dsic.upv.es:
 Dear Martin,

 I think that the (practical) reason is avoiding equality checks during
 pattern matching.

 For instance, how do you evaluate this:

  foo ((+1):(1+):[])    ?

 Both expressions in the first and second entries of the list are
 semantically equivalent,
 but from an operational point of view, you have to ensure the equality of
 two functions
 over an infinite domain (of integer numbers).

 Best regards,

 Salvador.


 Martin Hofmann escribió:

 It is pretty clear, that the following is not a valid Haskell pattern:

 foo (x:x:xs) = x:xs

 My questions is _why_ this is not allowed. IMHO, the semantics should be
 clear: The pattern is expected to succeed, iff 'x' is each time bound to
 the same term.
 Isn't this allowed, because this would require a strict evaluation of
 the 'x' variables?

 Thanks,

 Martin

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] I have forgotten .. my bad

2009-05-15 Thread Dougal Stanton
On Fri, May 15, 2009 at 5:30 AM, Vasili I. Galchin vigalc...@gmail.com wrote:
 Hello,

    darcs get --init ?? I want to pull down Data.FiniteMap. I
 have forgotten the path to Hackage .. I tried 

  sudo darcs get http://hackage.haskell.org/ Data.FiniteMap
 [sudo] password for vigalchin:
 Invalid repository:  http://hackage.haskell.org

 darcs failed:  Failed to download URL
 http://hackage.haskell.org/_darcs/inventory : HTTP error (404?)

 ??

 Obviously the code I am cabalizing needs to be upgraded(i.e. not using
 deprecated packages) but first I want it to build!

If you want to install something from Hackage, use

$ cabal install foo

If you want to grab the source

$ darcs get --partial path/to/repo

(Omit the --partial flag if you want the full source tree, but if
you're not intending to do serious work on the source it's probably
not worth it.)

From the error message above you appear to be darcs getting the root
directory of the hackage server, which isn't a valid repository.

Cheers,

D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Conor McBride

Hi

On 15 May 2009, at 09:11, Sittampalam, Ganesh wrote:


Martin Hofmann wrote:
It is pretty clear, that the following is not a valid Haskell  
pattern:


foo (x:x:xs) = x:xs

My questions is _why_ this is not allowed. IMHO, the semantics should
be
clear: The pattern is expected to succeed, iff 'x' is each time bound
to the same term.


That's what my daddy did in 1970. It was an extension of
LISP with pattern matching. He used EQUAL. That makes me
one of the few functional programmers who's had this
feature taken away from them. I'm not weeping, but I do
miss it.



How do you define the same term?

One natural way of compiling it would be to

foo (x:y:xs) | x == y = x:xs

but then pattern matching can introduce Eq constraints which some  
might

see as a bit odd.


Doesn't seem that odd to me. Plenty of other language features
come with constraints attached.




Isn't this allowed, because this would require a strict evaluation of
the 'x' variables?


The translation into == would probably introduce some strictness, for
most implementations of Eq. I don't think this is a huge problem in
itself.


There's some conceptual ugliness in that such a mechanism
*relies* on fall-through. In principle a sequence of guardless
patterns can always be fleshed out (at some cost) to disjoint
patterns. What precisely covers the case disjoint from (x, x)?

This is fixable if one stops quibbling about guardlessness,
or even if one adds inequality patterns.

One certainly needs a convention about the order in which
things happen: delaying equality tests until after constructor
matching --- effectively the guard translation --- seems
sensible and preserves the existing compilation regime.
Otherwise, repeated pattern variables get (==)-tested, linear
ones are lazy. Meanwhile, yes the semantics depends on the
implementation of (==), but what's new? That's true of do too.

The guard translation: linearize the pattern, introducing
new vars for all but the leftmost occurrence of repeated
vars. For each new x' made from x, add a guard x == x'. The
new guards should come in the same order as the new variables
and stand before any other guards present.

Presumably one can already cook up an ugly version of this
with view patterns ((x ==) - True).

It seems to me that the only questions of substance remaining
is whether improved clarity in normal usage is worth a little
more translational overhead to unpick what's wrong when weird
things happen, and whether any such gain is worth the effort
in implementation.

I miss lots of stuff from when I was a kid. I used to write

  elem x (_ ++ x : _)  = True
  elem _ _ = False

and think that was cool. How dumb was I?

Cheers

Conor

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-15 Thread John Lato
leimy2k:
 On Thu, May 14, 2009 at 8:46 PM, Don Stewart d...@galois.com wrote:

 leimy2k:
 
 
  On Thu, May 14, 2009 at 8:40 PM, Don Stewart d...@galois.com wrote:
 
      leimy2k:
       I actually need little endian encoding... wondering if anyone else
 hit
      this
       with Data.Binary. (because I'm working with Bell Lab's 9P protocol
 which
      does
       encode things on the network in little-endian order).
      
       Anyone got some tricks for this?
 
      Yes!
      There are big, little and host-endian primitives in the Get/Put
 monads.
 
 
 http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/
      Data-Binary-Put.html#v%3AputWord16le
 
      You can use these to build encoders directly.
 
 
  Cool... I just have to write my own encoder and decoder now.
 
  As a request could we get encodeLe decodeLe for a later version of this
  library?  :-)  That'd be totally awesome.

 Oh, you mean entirely different instances for all the current ones, that
 use LE encodings?


 Well the library is leaning towards Network Byte Order in that it has
 encode/decode that only encode/decode for Big Endian.

 Us folks who have to do little endian all now have to write our own
 encoding/decoding :-)

 I'm speaking specifically of the encode/decode functions.  I have no idea
 how they're implemented.

The encode/decode functions just call the runGet/runPut functions for
whatever is being encoded or decoded to combined with the get/put
functions from the Binary instance.  The endian-ness is entirely
determined by the Binary instance for the data type you're
encoding/decoding, not anything in the encode/decode functions
themselves.

For data types you define, you can make the Binary instance LE
standard (although it may not be a good idea) by using the
little-endian primitives Don mentioned.  For built-in types, if you
want to use a different endian-ness, you can make new get/put
functions then call runGet/runPut on those directly.  You won't be
able to redefine the Binary instances, but if you'll be doing this
with a lot of different types you could make your own BinaryLE class
like this:

class BinaryLE t where
  putLE :: t - Put
  getLE :: Get t

encodeLE :: BinaryLE a = a - ByteString
encodeLE = runPut . putLE

decodeLE :: BinaryLE a = ByteString - a
decodeLE = runGet getLE

I've done some work with Binary and little-endian, and this bias never
really bothered me (I think it's actually a host-endian bias, could be
mistaken).  I was using my own data types so I had to make my own
custom Binary instances, which I would have had to do anyway.  The
data format specified little-endian, so making the Binary instance
LE-standard seemed appropriate.

You'd only need to re-make custom get/put functions if you're using
types that already have Binary instances, and you intend to manipulate
the data outside of Haskell.  Does that describe your situation?

John
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] I have forgotten .. my bad

2009-05-15 Thread Jason Dagit
On Thu, May 14, 2009 at 9:30 PM, Vasili I. Galchin vigalc...@gmail.com wrote:
 Hello,

    darcs get --init ?? I want to pull down Data.FiniteMap. I
 have forgotten the path to Hackage .. I tried 

  sudo darcs get http://hackage.haskell.org/ Data.FiniteMap
 [sudo] password for vigalchin:

I don't know what your machine is configured like, but I'm rather
surprised to see you use 'sudo' with darcs.  In case you're not
already familiar with the purpose of sudo, I'll explain.  The purpose
is to give the command the same privileges as root, the super user.
Effectively, you're giving darcs full range over your computer.
Although, this should be harmless in the case of darcs, it is usually
a bad idea to give commands superuser privileges unless they really
need it :)

Good luck!
Jason
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread wren ng thornton

Conor McBride wrote:

Hi

Sittampalam, Ganesh wrote:
 Martin Hofmann wrote:
  It is pretty clear, that the following is not a valid Haskell pattern:
 
  foo (x:x:xs) = x:xs
 
  My questions is _why_ this is not allowed. IMHO, the semantics should
  be
  clear: The pattern is expected to succeed, iff 'x' is each time bound
  to the same term.

That's what my daddy did in 1970. It was an extension of
LISP with pattern matching. He used EQUAL. That makes me
one of the few functional programmers who's had this
feature taken away from them. I'm not weeping, but I do
miss it.


On the one hand, unification is awesome; on the other hand, pattern 
matching is simple. The nice thing about the simplicity is that it's 
easy to compile into efficient code, and it's easy to 
explain/understand. Unification has all sorts of unfortunate 
consequences[1] and it's much harder to explain to the uninitiated.


Curry[2] has features like this, but then it has full 
backtracking-search logic programming. It might be interesting to see if 
a more restricted form is useful in Haskell, though it should be an 
optional feature IMO so that it can be disabled for guaranteed-efficient 
patterns and typo detection.



[1] e.g. optimal factoring of an unordered set of Prolog terms is 
NP-complete. For a fixed ordering there are good algorithms, and Haskell 
has fixed ordering due to the semantics of overlapping patterns, but 
this should still give some clues about what lurks beneath.


[2] http://www.curry-language.org/



 How do you define the same term?

 One natural way of compiling it would be to

 foo (x:y:xs) | x == y = x:xs

 but then pattern matching can introduce Eq constraints which some might
 see as a bit odd.

Doesn't seem that odd to me. Plenty of other language features
come with constraints attached.


Another option is to use structural matching all the way down. This has 
the benefit of not calling user-defined code, though it has the 
disadvantages of not matching heterogeneous but semantically-equal 
values. Of course, by removing the Eq constraint this also re-raises the 
specter of comparing functions. But it's a good Devil's Advocate 
definition to bear in mind.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Claus Reinke

I miss lots of stuff from when I was a kid. I used to write

  elem x (_ ++ x : _)  = True
  elem _ _ = False

and think that was cool. How dumb was I?


Yeah, the Kiel Reduction Language had similarly expressive
and fun pattern matching, with subsequence matching and 
backtracking if the guard failed. Of course, these days, you 
could use view patterns for the simpler cases, but it doesn't 
look quite as nice:


   elem x (break (==x) - (_, _:_)) = True
   elem _ _ = False

and gets ugly enough to spoil the fun quickly:

   -- lookup key (_++((key,value):_)) = Just value
   lookup key (break ((==key).fst) - (_ , (_,value):_)) = Just value
   lookup _   _  = Nothing

Also, view patterns don't handle match failure by an implicit
Monad, let alone MonadPlus, so one often has to insert an
explicit Maybe, and there is no backtracking:-(

Claus

-- Nostalgia isn't what it used to be [source: ?]


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-15 Thread Duncan Coutts
On Thu, 2009-05-14 at 20:46 -0700, David Leimbach wrote:
 
 
 On Thu, May 14, 2009 at 8:40 PM, Don Stewart d...@galois.com wrote:
 leimy2k:
 
  I actually need little endian encoding... wondering if
 anyone else hit this
  with Data.Binary. (because I'm working with Bell Lab's 9P
 protocol which does
  encode things on the network in little-endian order).
 
  Anyone got some tricks for this?
 
 
 Yes!
 There are big, little and host-endian primitives in the
 Get/Put monads.
 
 
  
 http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/Data-Binary-Put.html#v%3AputWord16le
 
 You can use these to build encoders directly.
 
 
 Cool... I just have to write my own encoder and decoder now.
 
 
 As a request could we get encodeLe decodeLe for a later version of
 this library?  :-)  That'd be totally awesome.

The thing you're missing (and which admittedly is not clear) is that the
binary package has two parts. One is a layer where you get full control
over the binary representation. The other is a portable serialisation
layer for pickling and unpickling Haskell values. That pickling layer
(ie the Binary class) is not for working with externally-defined binary
formats.

It might seem like we could co-opt the Binary class for this purpose eg
by parametrising by a dozen things like endian, padding, etc etc but I
don't think it scales or is sufficiently flexible (and it'd be slow).

What is missing in the binary package is a nice set of combinators for
using the low level layer to easily construct parsers for
externally-defined formats. That's what you'd want for your P9 protocol.

To reduce confusion we should also split the Haskell picking layer from
the lower layer.

This has been on our TODO list for some time. It needs to be done pretty
carefully however and we've not really had the time.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Sittampalam, Ganesh
Conor McBride wrote:
 On 15 May 2009, at 09:11, Sittampalam, Ganesh wrote:

 but then pattern matching can introduce Eq constraints which some
 might see as a bit odd.
 
 Doesn't seem that odd to me. Plenty of other language features come
 with constraints attached. 

It's the introduction of a constraint from tweaking a pattern that is
odd, I think. By way of precedent H98 rejected this kind of idea in
favour of putting 'fail' into Monad.

Ganesh

=== 
 Please access the attached hyperlink for an important electronic 
communications disclaimer: 
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
 
=== 
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Lennart Augustsson
In the original language design the Haskell committee considered
allowing multiple occurrences of the same variable in a pattern (with
the suggested equality tests), but it was rejected in favour of
simplicity.

  -- Lennart

On Fri, May 15, 2009 at 11:30 AM, Sittampalam, Ganesh
ganesh.sittampa...@credit-suisse.com wrote:
 Conor McBride wrote:
 On 15 May 2009, at 09:11, Sittampalam, Ganesh wrote:

 but then pattern matching can introduce Eq constraints which some
 might see as a bit odd.

 Doesn't seem that odd to me. Plenty of other language features come
 with constraints attached.

 It's the introduction of a constraint from tweaking a pattern that is
 odd, I think. By way of precedent H98 rejected this kind of idea in
 favour of putting 'fail' into Monad.

 Ganesh

 ===
  Please access the attached hyperlink for an important electronic 
 communications disclaimer:
  http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
  ===

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Conor McBride


On 15 May 2009, at 12:07, Lennart Augustsson wrote:


In the original language design the Haskell committee considered
allowing multiple occurrences of the same variable in a pattern (with
the suggested equality tests), but it was rejected in favour of
simplicity.


Simplicity for whom, is the question? My point is
only that there's no technical horror to the proposal.
It's just that, given guards, the benefit (in simplicity
of program comprehension) of nonlinear patterns over
explicit == is noticeable but hardly spectacular.

Rumblings about funny termination behaviour, equality
for functions, and the complexity of unification (which
isn't the proposal anyway) are wide of the mark. This
is just an ordinary cost-versus-benefit issue. My guess
is that if this feature were already in, few would be
campaigning to remove it. (By all means step up and say
why!) As it's not in, it has to compete with other
priorities: I'm mildly positive about nonlinear
patterns, but there are more important concerns.

Frankly, the worst consequence I've had from Haskell's
pattern linearity was just my father's derision. He
quite naturally complained that his programs had lost
some of their simplicity.

All the best

Conor

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Miguel Mitrofanov



Conor McBride wrote on 15.05.2009 16:19:

My guess is that if this feature were already in, few would be campaigning to 
remove it.


You're probably right. For example, I'm not compaigning  to remove multiple inheritance (from non-abstract classes) from C++. But I still think 
it's an ugly feature, it'd be better not to have it, it's encouraging bad design etc. The same for this Eq-patterns.


BTW, why stop on (x:x:xs)? Let's use patterns like (x:factorial(x):xs), or (factorial(x):x:xs), or (factorial(x):xs)... No, wait, the last 
pattern would be impossible to compile. But I think you've got the point.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Pretty printing a tree

2009-05-15 Thread Matthias Görgens
Hello,

Or --- if you just want pretty trees and you are not confined to the
command line: You can generate GraphViz code and use that program to
draw your tree in PostScript.  (There is also a GraphViz-package, but
generating the code yourself is easy.)

Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Lennart Augustsson
Simplicity of pattern matching semantics, not of implementation (we
all knew how to implement it).
Miranda had non-linear patterns, but nobody really argued for them in Haskell.
If Haskell had them, I'd not argue to have them removed, but nor will
I argue to add them.

  -- Lennart

On Fri, May 15, 2009 at 1:19 PM, Conor McBride
co...@strictlypositive.org wrote:

 On 15 May 2009, at 12:07, Lennart Augustsson wrote:

 In the original language design the Haskell committee considered
 allowing multiple occurrences of the same variable in a pattern (with
 the suggested equality tests), but it was rejected in favour of
 simplicity.

 Simplicity for whom, is the question? My point is
 only that there's no technical horror to the proposal.
 It's just that, given guards, the benefit (in simplicity
 of program comprehension) of nonlinear patterns over
 explicit == is noticeable but hardly spectacular.

 Rumblings about funny termination behaviour, equality
 for functions, and the complexity of unification (which
 isn't the proposal anyway) are wide of the mark. This
 is just an ordinary cost-versus-benefit issue. My guess
 is that if this feature were already in, few would be
 campaigning to remove it. (By all means step up and say
 why!) As it's not in, it has to compete with other
 priorities: I'm mildly positive about nonlinear
 patterns, but there are more important concerns.

 Frankly, the worst consequence I've had from Haskell's
 pattern linearity was just my father's derision. He
 quite naturally complained that his programs had lost
 some of their simplicity.

 All the best

 Conor

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problem with haddock importing definition

2009-05-15 Thread Maurício
Hi,

I have a situation like this: module A imports R (a newtype
declaration) from module B, and lists it in its (module A)
export list.

Documentation for R is included by haddock in documentation
for module A, as I want. However, if my package exposes only
module A, documentation for R desapears.

So: if my .cabal file lists A and B in 'exposed-modules',
documentation for R is included in A documentation. If I remove
B from 'exposed-modules', R documentation in A desapears.

Do you know what should I do?

Thanks,
Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] #haskell.pt IRC channel

2009-05-15 Thread Marco Túlio Gontijo e Silva
Hello,

I'd like to invite all Portuguese speakers haskellers to join
#haskell.pt in irc.freenode.net.  I added it to the list in
http://www.haskell.org/haskellwiki/IRC_channel .

Greetings.
-- 
marcot
http://marcot.iaaeee.org/


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ICFP09 Accepted Papers

2009-05-15 Thread Matthew Fluet (ICFP Publicity Chair)
   Accepted Papers
ICFP 2009: International Conference on Functional Programming
  Edinburgh, Scotland, 31 August - 2 September 2009
  http://www.cs.nott.ac.uk/~gmh/icfp09.html

The ICFP 2009 Program Chair and Committee are pleased to announce that
the following papers have been accepted for the conference.

Additional information regarding the final program, invited speakers,
and registration will be forthcoming.  However, the Local Arrangements
Co-Chairs would like to remind participants of the following:

 * ICFP'09 coincides with the final week of the Edinburgh
   International Festival, one of the premier arts and cultural
   festivals in the world.  The opportunity to attend the Festival is
   a plus!  Due to the popularity of Edinburgh during the festival
   period, we recommend booking accommodation early.

More details regarding accommodation may be obtained from
the ICFP 2009 Local Arrangements webpage:
 http://www.haskell.org/haskellwiki/ICFP_2009_Local_Arrangements


   Accepted papers
   ~~~

A CONCURRENT ML LIBRARY IN CONCURRENT HASKELL
   Avik Chaudhuri

A THEORY OF TYPED COERCIONS AND ITS APPLICATIONS
   Nikhil Swamy, Michael Hicks and Gavin Bierman

A UNIVERSE OF BINDING AND COMPUTATION
   Daniel Licata and Robert Harper

ATTRIBUTE GRAMMARS FLY FIRST-CLASS: HOW TO DO ASPECT ORIENTED
PROGRAMMING IN HASKELL
   Marcos Viera, S. Doaitse Swierstra and Wouter S. Swierstra

AUTOMATICALLY RESTFUL WEB APPLICATIONS OR, MARKING MODULAR
SERIALIZABLE CONTINUATIONS
   Jay McCarthy

BEAUTIFUL DIFFERENTIATION
   Conal Elliott

BIORTHOGONALITY, STEP-INDEXING AND COMPILER CORRECTNESS
   Nick Benton and Chung-Kil Hur

CAUSAL COMMUTATIVE ARROWS AND THEIR OPTIMIZATION
   Hai Liu, Eric Cheng and Paul Hudak

COMPLETE AND DECIDABLE TYPE INFERENCE FOR GADTS
   Tom Schrijvers, Simon Peyton Jones, Martin Sulzmann and
   Dimitrios Vytiniotis

CONTROL-FLOW ANALYSIS OF FUNCTION CALLS AND RETURNS BY ABSTRACT
INTERPRETATION
   Jan Midtgaard and Thomas P. Jensen

EDUCATIONAL PEARL: FUN FOR FRESHMEN KIDS
   Matthias Felleisen, Robert Bruce Findler, Matthew Flatt and
   Shriram Krishnamurthi

EFFECTIVE INTERACTIVE PROOFS FOR HIGHER-ORDER IMPERATIVE PROGRAMS
   Adam Chlipala, Gregory Malecha, Greg Morrisett, Avraham Shinnar and
   Ryan Wisnesky

EXPERIENCE REPORT: EMBEDDED, PARALLEL COMPUTER-VISION WITH A
FUNCTIONAL DSL
   Ryan Newton and Teresa Ko

EXPERIENCE REPORT: HASKELL IN THE REALWORLD
   Curt Sampson

EXPERIENCE REPORT: OCAML FOR AN INDUSTRIAL-STRENGTH STATIC ANALYSIS
FRAMEWORK
   Pascal Cuoq and Julien Signoles

EXPERIENCE REPORT: OCSIGEN, A WEB PROGRAMMING FRAMEWORK
   Vincent Balat, Jérôme Vouillon and Boris Yakobowski

EXPERIENCE REPORT: SEL4 -- FORMALLY VERIFYING A HIGH-PERFORMANCE
MICROKERNEL
   Gerwin Klein, Philip Derrin and Kevin Elphinstone

FINDING RACE CONDITIONS IN ERLANG WITH QUICKCHECK AND PULSE
   Koen Claessen, Michal Palka, Nicholas Smallbone, John Hughes,
   Hans Svensson, Thomas Arts and Ulf Wiger

FREE THEOREMS INVOLVING TYPE CONSTRUCTOR CLASSES
   Janis Voigtlaender

GENERIC PROGRAMMING WITH FIXED POINTS FOR MUTUALLY RECURSIVE DATATYPES
   Alexey Rodriguez, Stefan Holdermans, Andres Löh and Johan Jeuring

IDENTIFYING QUERY INCOMPATIBILITIES WITH EVOLVING XML SCHEMAS
   Pierre Geneves, Nabil Layaida and Vincent Quint

IMPLEMENTING FIRST-CLASS POLYMORPHIC DELIMITED CONTINUATIONS BY A
TYPE-DIRECTED SELECTIVE CPS-TRANSFORM
   Tiark Rompf, Ingo Maier and Martin Odersky

LA TOUR D'HANOï
   Ralf Hinze

NON-PARAMETRIC PARAMETRICITY
   Georg Neis, Derek Dreyer and Andreas Rossberg

OXENSTORED: AN EFFICIENT HIERARCHICAL AND TRANSACTIONAL DATABASE USING
FUNCTIONAL PROGRAMMING WITH REFERENCE CELL COMPARISONS
   Thomas Gazagnaire and Vincent Hanquez

PARALLEL CONCURRENT ML
   John Reppy, Claudio Russo and Yingqi Xiao

PARTIAL MEMOIZATION OF CONCURRENCY AND COMMUNICATION
   Suresh Jagannathan, KC Sivaramakrishnan and Lukasz Ziarek

PURELY FUNCTIONAL LAZY NON-DETERMINISTIC PROGRAMMING
   Sebastian Fischer, Oleg Kiselyov and Chung-chieh Shan

RUNTIME SUPPORT FOR MULTICORE HASKELL
   Simon Marlow, Simon Peyton Jones and Satnam Singh

SAFE FUNCTIONAL REACTIVE PROGRAMMING THROUGH DEPENDENT TYPES
   Neil Sculthorpe and Henrik Nilsson

SCRIBBLE: CLOSING THE BOOK ON AD HOC DOCUMENTATION TOOLS
   Matthew Flatt, Eli Barzilay and Robert Bruce Findler

USING OBJECTIVE CAML TO DEVELOP SAFETY-CRITICAL EMBEDDED TOOL IN A
CERTIFICATION FRAMEWORK
   Bruno Pagano, Olivier Andrieu, Thomas Moniot, Benjamin Canou,
   Emmanuel Chailloux, Philippe Wang, Pascal Manoury and
   Jean-Louis Colaco
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-15 Thread David Leimbach
This approach looks like it'd work just fine.

On Fri, May 15, 2009 at 2:16 AM, John Lato jwl...@gmail.com wrote:

 leimy2k:
  On Thu, May 14, 2009 at 8:46 PM, Don Stewart d...@galois.com wrote:
 
  leimy2k:
  
  
   On Thu, May 14, 2009 at 8:40 PM, Don Stewart d...@galois.com wrote:
  
   leimy2k:
I actually need little endian encoding... wondering if anyone
 else
  hit
   this
with Data.Binary. (because I'm working with Bell Lab's 9P
 protocol
  which
   does
encode things on the network in little-endian order).
   
Anyone got some tricks for this?
  
   Yes!
   There are big, little and host-endian primitives in the Get/Put
  monads.
  
  
  http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/
   Data-Binary-Put.html#v%3AputWord16le
  
   You can use these to build encoders directly.
  
  
   Cool... I just have to write my own encoder and decoder now.
  
   As a request could we get encodeLe decodeLe for a later version of
 this
   library?  :-)  That'd be totally awesome.
 
  Oh, you mean entirely different instances for all the current ones, that
  use LE encodings?
 
 
  Well the library is leaning towards Network Byte Order in that it has
  encode/decode that only encode/decode for Big Endian.
 
  Us folks who have to do little endian all now have to write our own
  encoding/decoding :-)
 
  I'm speaking specifically of the encode/decode functions.  I have no idea
  how they're implemented.

 The encode/decode functions just call the runGet/runPut functions for
 whatever is being encoded or decoded to combined with the get/put
 functions from the Binary instance.  The endian-ness is entirely
 determined by the Binary instance for the data type you're
 encoding/decoding, not anything in the encode/decode functions
 themselves.

 For data types you define, you can make the Binary instance LE
 standard (although it may not be a good idea) by using the
 little-endian primitives Don mentioned.  For built-in types, if you
 want to use a different endian-ness, you can make new get/put
 functions then call runGet/runPut on those directly.  You won't be
 able to redefine the Binary instances, but if you'll be doing this
 with a lot of different types you could make your own BinaryLE class
 like this:

 class BinaryLE t where
  putLE :: t - Put
  getLE :: Get t

 encodeLE :: BinaryLE a = a - ByteString
 encodeLE = runPut . putLE

 decodeLE :: BinaryLE a = ByteString - a
 decodeLE = runGet getLE

 I've done some work with Binary and little-endian, and this bias never
 really bothered me (I think it's actually a host-endian bias, could be
 mistaken).  I was using my own data types so I had to make my own
 custom Binary instances, which I would have had to do anyway.  The
 data format specified little-endian, so making the Binary instance
 LE-standard seemed appropriate.

 You'd only need to re-make custom get/put functions if you're using
 types that already have Binary instances, and you intend to manipulate
 the data outside of Haskell.  Does that describe your situation?

 John
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] TFM09: Last CFP (Formal Methods Week, Eindhoven, November 6th 2009)

2009-05-15 Thread J.N. Oliveira


TFM2009
 2nd Int. FME Conference on Teaching Formal Methods
Widening Access to Formal Methods

   Friday, November 6th 2009, co-located with
 FM2009 : 16th International Symposium on Formal Methods
Eindhoven, the Netherlands, November 2 - November 6, 2009

   CALL FOR PAPERS

(URL: http://www.di.uminho.pt/tfm09)


1. About the conference
---
Ten years after the First World Formal Methods Congress (FM'99) in  
Toulouse,
formal methods communities from all over the world will once again  
have an
opportunity to come together.  As part of the First Formal Methods  
Week event
surrounding the FM2009 conference in Eindhoven, Formal Methods Europe  
will
be organizing TFM2009, the Second International Conference on  
Teaching Formal

Methods.

The conference will serve as a forum to explore the successes and  
failures

of Formal Methods (FM) education, and to promote cooperative projects to
further education and training in FMs. We would like to provide a  
forum for
lecturers, teachers, and industrial partners to discuss their  
experience,

present their pedagogical methodologies, and explore best practices.

TFM2009 follows in a series of recent events on teaching formal methods,
including: two BCS-FACS TFM workshops (Oxford in 2003, and London in  
2006),

the TFM 2004 conference in Ghent (with proceedings published as Springer
LNCS Volume 3294), the FM-Ed 2006 workshop (Hamilton, co-located with  
FM'06),

FORMED (Budapest, at ETAPS 2008), FMET 2008 (Kitakyushu 2008, co-located
with ICFEM), etc.

2. Topics of interest
-
Formal methods (FM) have an important role to play in the development of
complex computing systems - a role acknowledged in industrial  
standards such
as IEC 61508 and ISO/IEC 15408, and in the increasing use of precise  
modeling

notations, semantic markup languages, and model-driven techniques. There
is a growing need for software engineers who can work effectively  
with simple,
mathematical abstractions, and with practical notions of inference  
and proof.
However, there is little clear guidance ? for educators, for  
managers, or
for the engineers themselves ? as to what might comprise a basic  
education
in FM. Neither the present IEEE/ACM Software Engineering Body of  
Knowledge
(SWEBOK) nor the forthcoming Graduate Software Engineering Reference  
Curriculum
(GSWERC) provide the kind of specific information that teachers and  
practitioners

need to establish an adequate, balanced programme of learning in FM.

Original contributions are solicited that provide insight, opinions, and
suggestions for courses of action regarding the teaching FMs,  
including but

not limited to the following aspects:

* experiences of teaching FMs, both successful and unsuccessful;
* educational resources including the use of books, case studies  
and the internet;

* the education of weak and mathphobic students;
* the integration, or otherwise, of FMs into the curriculum,  
including
  contributions to the definition of a Formal Methods Body of  
Knowledge (FMBOK);

* the advantages of FM-trained graduates in the workplace;
* changing attitudes towards FMs in students, academic staff and  
practitioners;

* the necessary mathematical background.

The conference proceedings will be published by Springer-Verlag in  
the LNCS series.

Submissions may be up to 20 pages long using Springer's LNCS format.

3. Important dates
--
Please put the following dates in your diary:

Submission deadline May 25, 2009
Notification of acceptance  July 6, 2009
Final version   August 3, 2009

4. How to submit

Papers for TFM2009 will be processed through the EasyChair conference  
management system.To submit your paper, please visit:


  http://www.easychair.org/conferences/?conf=tfm2009

5. Invited speakers
---
To be announced

6. Programme Committee
--
Izzat Alsmadi   (North Dakota State University, USA)
Dines Bjorner   (IIMM Institute, Denmark)
Eerke Boiten(University of Kent, UK)
Raymond Boute   (Universiteit Gent, Belgium)
Andrew Butterfield  (Trinity College, Dublin)
Jim Davies  (University of Oxford, UK)
David Duce  (Oxford Brookes University, UK)
John Fitzgerald (University of Newcastle upon Tyne, UK)
Jeremy Gibbons  (University of Oxford, UK)
Randolph Johnson(National Security Agency, USA)
Michael Mac an Airchinnigh  (Trinity College, Dublin)
Dino Mandrioli  (Politecnico di Milano, Italy)
Jose Oliveira   (Universidade do Minho, Portugal)
Kees Pronk  (Technische Universiteit Delft, NL)
Bernhard Schaetz(Tecnical University of Munique, Germany)
Wolfgang Schreiner  (Johannes Kepler University Linz, Austria)
Simao Melo de Sousa (Universidade da 

Re: [Haskell-cafe] I have forgotten .. my bad

2009-05-15 Thread Vasili I. Galchin
I mean what is the path to Hackage repo?

Vasili

On Fri, May 15, 2009 at 4:32 AM, Jason Dagit da...@codersbase.com wrote:

 On Thu, May 14, 2009 at 9:30 PM, Vasili I. Galchin vigalc...@gmail.com
 wrote:
  Hello,
 
 darcs get --init ?? I want to pull down Data.FiniteMap. I
  have forgotten the path to Hackage .. I tried 
 
   sudo darcs get http://hackage.haskell.org/ Data.FiniteMap
  [sudo] password for vigalchin:

 I don't know what your machine is configured like, but I'm rather
 surprised to see you use 'sudo' with darcs.  In case you're not
 already familiar with the purpose of sudo, I'll explain.  The purpose
 is to give the command the same privileges as root, the super user.
 Effectively, you're giving darcs full range over your computer.
 Although, this should be harmless in the case of darcs, it is usually
 a bad idea to give commands superuser privileges unless they really
 need it :)

 Good luck!
 Jason

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: I have forgotten .. my bad

2009-05-15 Thread Benedikt Huber

Vasili I. Galchin schrieb:

Hello,

   darcs get --init ?? I want to pull down Data.FiniteMap. I 
have forgotten the path to Hackage .. I tried 

Hi Vasili,
Hackage does not host the darcs repositories.
You can get the FinitMap's source code via

 cabal unpack FiniteMap

though.

benedikt




 sudo darcs get http://hackage.haskell.org/ Data.FiniteMap
[sudo] password for vigalchin:
Invalid repository:  http://hackage.haskell.org

darcs failed:  Failed to download URL 
http://hackage.haskell.org/_darcs/inventory : HTTP error (404?)


??

Obviously the code I am cabalizing needs to be upgraded(i.e. not using 
deprecated packages) but first I want it to build!
 


Thanks,

Vasili





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Don't play with your monads...

2009-05-15 Thread David Leimbach
eventually you'll go bind.
Sorry couldn't resist.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Don't play with your monads...

2009-05-15 Thread Ertugrul Soeylemez
David Leimbach leim...@gmail.com wrote:

 eventually you'll go bind.
 Sorry couldn't resist.

I'd rather go pure joyn.


Greets,
Ertugrul.


-- 
nightmare = unsafePerformIO (getWrongWife = sex)
http://blog.ertes.de/


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: RESTng 0.1 + RedHandlers 0.1 (request handlers) + YuiGrids 0.1 (yahoo grids)

2009-05-15 Thread Sergio Urinovsky
I'd like to announce the release of 3 new packages in hackage developed for
a RESTful web framework called RESTng.

They are experimental, the framework is incomplete and we are currently not
actively developing it.
There are several interesting features so we have decided to release them to
share the ideas.


*RESTng:* A framework for writing RESTful applications. Features that may be
of interest are:

 * Resource presentation with annotations (implemented with Grids):
Resources are annotated with related data and all ends in boxes using grids.
i.e., an annotation for a book resource could be its author (the author
resource), and also their comments, so the book, the author and their
comments are shown in boxes. Annotations can have arbitrary data, but there
are some generic ones already available.

 * Hierarchical URLs are automatically handled. i.e.: Can easily define that
a book resource has many chapters, then these actions are defined:
  GET http://site/book/3/chapter/1(get the chapter 1 of book
with id 3)
  GET http://site/book/3/chapter/new  (get a form for filling data
for the new chapter for book with id 3)
  POST http://site/book/3/chapter/new (create a new chapter for the
book with id 3)
  and so on for updates, list and delete actions

 * ORM generates tables from haskell records (currently only PostgreSQL is
supported in the ORM).

 * Associations has many defined for models. Making available functions to
query for the parent and children so you don't have to make the SQL query.

 * Associations can be polymorphic so a comment can be associated to
different resources types. A record for a comment on a book, another for a
comment on a post.

 * Tags, Ratings, Comments, Users and login and CMS-like form fields
validations supported.



*YuiGrids:*
  * Containers and boxes with layout hints are specified. i.e:
 - Box A: in left side bar, near the bottom, with this content 
 - Container B: in the main part of the page, near the top, with 3
columns and these let's say 14 boxes inside ... (including Box C)
 - Box C: in the left column of three, with this other content ...

  * Tries to satisfy the layout hints. Not allways possible, i.e: if every
box has layout hint to go near the bottom, some of them will go at the top.

  * Boxes can have CSS specifications.

  * All is rendered into Yahoo grids (http://developer.yahoo.com/yui/grids).


  Currently, the YuiGrids uses own contextual html combinators are also
implemented in this package (called CxML here) instead of Text.XHtml for
keeping track of html parts like inline CSSs to be rendered at the head.
This can be improved to use the standard Text.XHtml library.



*RedHandlers:* It is another HTTP request handlers library to build
standalone web apps.
 * They deal with request data as usual.
 * There are also combinators for mapping part of the URL to public folders
in the file system.
 * And one for sending files efficiently in the response (a fork of the HTTP
library was necessary for this, included here).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GSoC project for EclipseFP

2009-05-15 Thread Henning Thielemann


On Thu, 14 May 2009, Thomas ten Cate wrote:


I'm happy to announce that my Google Summer of Code project proposal,
titled Extend EclipseFP functionality for Haskell, has been
accepted! This means that I will be working on EclipseFP during the
upcoming months.


Great news!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Example code won't compile

2009-05-15 Thread michael rice
Why won't this code compile?

Michael

===

{- Author: Jeff Newbern
   Maintainer: Jeff Newbern jnewb...@nomaware.com
   Time-stamp: Thu Aug 14 09:53:53 2003
   License:    GPL
-}

{- DESCRIPTION

Example 14 - Using the IO monad

Usage: Compile the code to produce a poor replacement for
   the standard Unix tr command.

Try: cat file | ./ex14 aeiou X
 cat file | ./ex14   _
 ./ex14 abc
-}

import Monad
import System
import IO
import Control.Monad.Error

-- translate char in set1 to corresponding char in set2
translate :: String - String - Char - Char
translate [] _  c = c
translate (x:xs) [] c = if x == c then ' ' else translate xs []  c
translate (x:xs) [y]    c = if x == c then  y  else translate xs [y] c
translate (x:xs) (y:ys) c = if x == c then  y  else translate xs ys  c

-- translate an entire string
translateString :: String - String - String - String
translateString set1 set2 str = map (translate set1 set2) str

usage :: IOError - IO ()
usage e = do putStrLn Usage: ex14 set1 set2
 putStrLn Translates characters in set1 on stdin to the 
corresponding
 putStrLn characters from set2 and writes the translation to 
stdout.

-- translates stdin to stdout based on commandline arguments
main :: IO ()
main = (do [set1,set2] - getArgs
   contents    - hGetContents stdin
   putStr $ translateString set1 set2 contents)
   `catchError` usage

-- END OF FILE

=

[mich...@localhost ~]$ ghc ex14.hs -o ex14
ex14.o: In function `rF8_info':
(.text+0x48): undefined reference to 
`mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure'
ex14.o: In function `sGp_info':
(.text+0x861): undefined reference to 
`mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure'
ex14.o: In function `sGp_info':
(.text+0x91d): undefined reference to 
`__stginit_mtlzm1zi1zi0zi2_ControlziMonadziError_'
ex14.o: In function `rF8_info':
(.text+0x50): undefined reference to 
`mtlzm1zi1zi0zi2_ControlziMonadziErrorziClass_zdp1MonadError_info'
ex14.o: In function `sGp_info':
(.text+0x869): undefined reference to 
`mtlzm1zi1zi0zi2_ControlziMonadziErrorziClass_catchError_info'
ex14.o: In function `rF8_srt':
(.data+0x0): undefined reference to 
`mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure'
ex14.o: In function `Main_main_srt':
(.data+0x6c): undefined reference to 
`mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure'
collect2: ld returned 1 exit status
[mich...@localhost ~]$ 




  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Example code won't compile

2009-05-15 Thread Don Stewart
nowgate:
 Why won't this code compile?
 [mich...@localhost ~]$ ghc ex14.hs -o ex14

Missing --make

I'd also add -O2, but I'm like that.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Example code won't compile

2009-05-15 Thread michael rice
This example compiles fine without --make. What's the difference?

Michael

==

{- Author: Jeff Newbern
   Maintainer: Jeff Newbern jnewb...@nomaware.com
   Time-stamp: Wed Jul  2 18:11:36 2003
   License:    GPL
-}

{- DESCRIPTION

Example 13 - Using the List monad

Usage: Compile the code and execute the resulting program
   with various arguments.  Each argument will produce
   a list of possible parses of the argument as a decimal
   number, a hexadecimal number or a word.

Try: ./ex13 34 f3 bean
 ./ex13 food f00d
 ./ex13 beef 10 n!
 ./ex13 why? (punctuation)

-}

import Monad
import System
import Char

-- we can parse three different types of terms
data Parsed = Digit Integer | Hex Integer | Word String deriving Show

-- attempts to add a character to the parsed representation of a hex digit
parseHexDigit :: Parsed - Char - [Parsed]
parseHexDigit (Hex n) c = if isHexDigit c then
    return (Hex ((n*16) + (toInteger (digitToInt c
          else
    mzero
parseHexDigit _   _ = mzero

-- attempts to add a character to the parsed representation of a decimal digit
parseDigit :: Parsed - Char - [Parsed]
parseDigit (Digit n) c = if isDigit c then
   return (Digit ((n*10) + (toInteger (digitToInt c
 else
   mzero
parseDigit _ _ = mzero
           
-- attempts to add a character to the parsed representation of a word
parseWord :: Parsed - Char - [Parsed]
parseWord (Word s) c = if isAlpha c then
 return (Word (s ++ [c]))
   else
 mzero
parseWord _    _ = mzero

-- tries to parse the digit as a hex value, a decimal value and a word
-- the result is a list of possible parses
parse :: Parsed - Char - [Parsed]
parse p c = (parseHexDigit p c) `mplus` (parseDigit p c) `mplus` (parseWord p c)

-- parse an entire String and return a list of the possible parsed values
parseArg :: String - [Parsed]
parseArg s = do init - (return (Hex 0)) `mplus` (return (Digit 0)) `mplus` 
(return (Word ))
    foldM parse init s

-- show the original string and all possible parses for the string
showResult :: String - IO ()
showResult s = do putStr s
  putStr : 
  print (parseArg s)


-- prints possible parsed values for command-line arguments
main :: IO ()
main = do args - getArgs
  mapM_ showResult args

-- END OF FILE


--- On Fri, 5/15/09, Lennart Augustsson lennart.augusts...@gmail.com wrote:

From: Lennart Augustsson lennart.augusts...@gmail.com
Subject: Re: [Haskell-cafe] Example code won't compile
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org haskell-cafe@haskell.org
Date: Friday, May 15, 2009, 7:25 PM

--make

   -- Lennart (iPhone)




  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread wren ng thornton

Conor McBride wrote:

Rumblings about funny termination behaviour, equality
for functions, and the complexity of unification (which
isn't the proposal anyway)


But unification is what you get by adding non-linearity. Sure, all terms 
are ground; would you prefer I said testing for membership in an 
element of the RATEG class?



For more ickiness about RATEG, it's not closed under compliment and the 
emptiness problem is undecidable (so dead code elimination can't always 
work). Even restricting to the closed subset (aka tree-automata with 
(dis-)equality constraints) leaves emptiness undecidable, though there 
are a couple still more restricted classes that are decidable.


cf ch.4 of TATA http://tata.gforge.inria.fr/

--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Example code won't compile

2009-05-15 Thread Krzysztof Skrzętnicki
The one important line is
 import Control.Monad.Error
It adds dependancy on mtl package, which is not used by default
(contrary to 'base' package, which includes Monad, System and IO
modules). With --make GHC adds it automatically. Therefore
$ ghc -package mtl ex14.hs
compiles fine. I'd recommend using --make. In rare occasions when
there is a namespace clash between packages one can simply hide
offending packages or specify preferred ones.

Best regards

Christopher Skrzętnicki
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Jason Dusek
  Algebraic datatypes are built and unpacked with constructors.
  Pattern matching is just a way to use these constructors.

  This is distinct from the kind of unification/validation that
  happens in logic languages like Prolog. There is no special list
  constructor for when the first two items are equal.

--
Jason Dusek
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Example code won't compile

2009-05-15 Thread michael rice
OK. Thanks, everyone.

Michael

--- On Fri, 5/15/09, Krzysztof Skrzętnicki gte...@gmail.com wrote:

From: Krzysztof Skrzętnicki gte...@gmail.com
Subject: Re: [Haskell-cafe] Example code won't compile
To: michael rice nowg...@yahoo.com
Cc: Lennart Augustsson lennart.augusts...@gmail.com, 
haskell-cafe@haskell.org haskell-cafe@haskell.org
Date: Friday, May 15, 2009, 9:55 PM

The one important line is
 import Control.Monad.Error
It adds dependancy on mtl package, which is not used by default
(contrary to 'base' package, which includes Monad, System and IO
modules). With --make GHC adds it automatically. Therefore
$ ghc -package mtl ex14.hs
compiles fine. I'd recommend using --make. In rare occasions when
there is a namespace clash between packages one can simply hide
offending packages or specify preferred ones.

Best regards

Christopher Skrzętnicki



  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Data.FiniteMap deprecrated

2009-05-15 Thread Vasili I. Galchin
Hello,

  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap
... since this is deprecated what is the orthodox way to implement finite
map??

Thanks,

Vasili
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe