Re: [Haskell-cafe] What is a simple pattern binding?

2011-06-26 Thread dm-list-haskell-cafe
At Sun, 26 Jun 2011 01:41:01 +0100,
Paterson, Ross wrote:
 
  I thought no type signature meant no type signature inside b1.
 
 No, it means no type signature for the variable.
 
  Otherwise, you are saying nothing could depend on a binding with a
  type signature.  By that logic, there can be no mutual dependence,
  and so every declaration with a type signature is its own (singleton)
  declaration group.
 
 A pattern binding can bind more than one variable.  If all the variables
 bound by a binding have type signatures, that binding is indeed a
 singleton declaration group.

If this is the case, then multiple sentences in the 2010 report don't
make sense, though the way in which they don't make sense sort of
depends on what simple pattern binding means.  Which of the
following constitute a simple pattern binding?

a.  a | False = undefined
  | otherwise = \x - x

b.  Just b = Just (\x - x)

c.  Just c | False = undefined
   | otherwise = Just (\x - x)

d.  (d, d') = (\x - x, d)

e.  (e, e') | False = undefined
| otherwise = (\x - x, e)

If it's any clue, GHC infers a polymorphic type for a only.  It infers
type GHC.Prim.Any - GHC.Prim.Any for the others.  Moreover, GHC
accepts the type signature a :: t - t, but rejects such a
polymorphic signature for the other variables, and also rejects
programs such as:

Just b = Just (\x - x)

f :: (Show a) = a - a
f = b -- illegal

So let's work under the assumption that a is a simple pattern binding,
and the others are not.  If you have a different definition, I'll make
a different argument.  (Note also that if you agree with this
definition, then there is a bug in section 4.4.3.2 of the report,
since a is not of the form p = e.  But if you take the 4.4.3.2
definition, then I'll argue section 4.5.5 has a bug.)

Let's posit a definition that accepts only a (and in particular that
rejects d and e).  Such a definition is further supported by the
phrase a simple pattern binding is a pattern binding in which the
pattern consists of only a single variable (from section 4.5.5).

If we accept that a simple pattern binding cannot bind more than one
variable, then the definition of the monomorphism restriction in
section 4.5.5 is not consistent with your interpretation of the term
declaration group.  After all, given our posited definition, the
following language in 4.5.5:

(a): every variable in the group is bound by a function binding
 or a simple pattern binding (Section 4.4.3.2), and

(b): an explicit type signature is given for every variable in
 the group that is bound by simple pattern binding.

should instead read:

   (a): every binding is a function binding, or

   (b): the group consists of a simple pattern binding with an
explicit type signature.

In particular, why would the report say an explicit type signature is
given for EVERY variable when there can be only one such variable?

David

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


[Haskell-cafe] Can't use libraries in haskell

2011-06-26 Thread Александр
Hello,


I'm new in haskell. I want to use xml library 
(http://hackage.haskell.org/package/xml) in my project. 

I downloaded it.then try to build and install: 
runhaskell Setup.hs configure

runhaskell Setup.hs build

runhaskell Setup.hs install
All ok. There are no errors. When i try import modules from this lib to my 
project, for example: 
import Text.XML.Light.Cursor
I get error: 
/home/shk/dev/src/XMPP.hs:8:8:
    Could not find module `Text.XML.Light.Cursor':
      Use -v to see a list of the files searched for.
Failed, modules loaded: none.

if i try:

 cabal install xml
Resolving dependencies... 
No packages to be installed. All the requested packages are already installed. 
If you want to reinstall anyway then use the --reinstall flag. 
What's wrong? How can i install and use library in haskell? 
Thank you. ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can't use libraries in haskell

2011-06-26 Thread Evan Laforge
 What's wrong? How can i install and use library in haskell?

First thing is to do 'ghc-pkg list'.  If your package doesn't show up
then it's not installed, according to the package registry.  'cabal
install' should have registered it.  If it is in the list, then it
depends how you're building.  If you use ghc manually, then you have
to give '-package xyz'.  If you use 'ghc --make', ghc will
automatically add the -package for you.  If you use cabal, you put the
package in the dependencies, and 'cabal build' will add -package for
you.

If the package has parens, then someone hid it, and you'll have to do
'ghc-pkg expose' on it.  If you're doing everything else right and it
still doesn't find the package, then you can run ghc -v and it'll
print lots of details.  It might have something about 'hiding xyz
because of some version thing', which means you're depending on
libraries that expect different versions of the underlying library.
You can sometimes get out of this by carefully upgrading or
downgrading certain libraries.

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


Re: [Haskell-cafe] Can't use libraries in haskell

2011-06-26 Thread Александр
Thank you, for reply.

Yes i use ghc.

First thing is to do 'ghc-pkg list'. If your package doesn't show up
then it's not installed, according to the package registry. 'cabal
install' should have registered it. If it is in the list, then it
depends how you're building. If you use ghc manually, then you have
to give '-package xyz'. If you use 'ghc --make', ghc will
automatically add the -package for you. If you use cabal, you put the
package in the dependencies, and 'cabal build' will add -package for
you.

If i want to use ghci to test any function from my project. How can i import 
lib then?

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


Re: [Haskell-cafe] What is a simple pattern binding?

2011-06-26 Thread Paterson, Ross
 If this is the case, then multiple sentences in the 2010 report don't
 make sense, though the way in which they don't make sense sort of
 depends on what simple pattern binding means.

Indeed, the Report has two problems:

Sections 4.4.3.2 and 4.5.5 have different definitions of simple pattern.
This has been there since section 4.5.5 (Monomorphism Restriction) was
added in Haskell 1.1.  But then the only technical use of the term is
in section 4.5.5.

When the definition of declaration group (section 4.5.1) was changed in
Haskell 2010 to break dependencies on type signatures, Rule 1 of the
Monomorphism Restriction (section 4.5.5), while not incorrect, became
partially redundant and overly complex.  It could have been simplified
along the lines you describe.

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


Re: [Haskell-cafe] Alex Lexer Performance Issues

2011-06-26 Thread Malcolm Wallace

On 22 Jun 2011, at 15:53, Tristan Ravitch wrote:

 On Wed, Jun 22, 2011 at 07:48:40AM +0100, Stephen Tetley wrote:
 How fast is good old String rather than ByteString?
 
 For lexing, String is a good fit (cheap deconstruction at the head /
 front). For your particular case, maybe it loses due to the large file
 size, maybe it doesn't...
 
 I gave it a shot and the percentages in the profile are approximately
 the same (and peak memory usage was about double).  I might end up
 having to parse the original binary format instead of the text format.

There is an old folklore that lexing is usually the most expensive phase of any 
compiler-like traversal.  50% of time and space expended on lexing was pretty 
common twenty years ago.

Regards,
Malcolm

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


Re: [Haskell-cafe] Data.Time

2011-06-26 Thread Malcolm Wallace

On 26 Jun 2011, at 01:53, Tony Morris wrote:

 Having only had a flirt with Data.Time previously, I assumed
 it would be robust like many other haskell libraries.

If, by lack of robustness, you mean that you get runtime errors, then consider 
them bugs, and file them with the author/maintainer accordingly.

If you mean something else, then being more specific might be useful.  I know 
that the first time I looked seriously at Data.Time it seemed rather byzantine 
and labyrinthine.  So many types!  So few direct conversions between them!  But 
when you think more closely about the domain, you realise that notions of time 
are not simple at all, and have varied widely over history, and the complexity 
of Data.Time only reflects the complexity of the domain.

The old-time package is still available, and has a much simplified approach to 
time (which is evidently wrong in many places), but may better suit the needs 
of applications that only care to be approximate.

Regards,
Malcolm

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


Re: [Haskell-cafe] commutative monoid?

2011-06-26 Thread Brent Yorgey
On Sat, Jun 25, 2011 at 02:34:47PM -0700, Evan Laforge wrote:
 On Sat, Jun 25, 2011 at 2:02 PM, Brent Yorgey byor...@seas.upenn.edu wrote:
  Actually, there are (at least) four: there's also the one where
  mappend = liftA2 mappend, i.e. introduce potential failure into a
  monoid operation defined on the values.  I wrote about it here:
 
     http://byorgey.wordpress.com/2011/04/18/monoids-for-maybe/
 
 Just out of curiosity, what was the problem that wanted this kind of
 monoid for the solution?  I always find concrete examples useful in
 addition to the abstract explorations and toy examples.

To be honest, I don't remember!

-Brent

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


[Haskell-cafe] Period of a sequence

2011-06-26 Thread michael rice
MathWorks has the function seqperiod(x) to return the period of sequence x. Is 
there an equivalent function in Haskell?

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


Re: [Haskell-cafe] Can't use libraries in haskell

2011-06-26 Thread Jason Dagit
2011/6/26 Александр kommunist1...@mail.ru:
 Thank you, for reply.

 Yes i use ghc.

First thing is to do 'ghc-pkg list'. If your package doesn't show up
then it's not installed, according to the package registry. 'cabal
install' should have registered it. If it is in the list, then it
depends how you're building. If you use ghc manually, then you have
to give '-package xyz'. If you use 'ghc --make', ghc will
automatically add the -package for you. If you use cabal, you put the
package in the dependencies, and 'cabal build' will add -package for
you.

 If i want to use ghci to test any function from my project. How can i import 
 lib then?

I find this is easiest with cabal-dev.  Here is a guide to using cabal-dev:
http://www.reddit.com/r/haskell/comments/f3ykj/psa_use_cabaldev_to_solve_dependency_problems/

When I want to test out a library in ghci I do the following:
mkdir -p ~/tmp/test-foo
cd ~/tmp/test-foo
cabal-dev install foo
cabal-dev ghci

That puts me in ghci with the newly installed foo available so then
you just type, :m + Data.Foo, or in recent ghci you can even type
import Data.Foo.

I hope that helps,
Jason

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


Re: [Haskell-cafe] What is a simple pattern binding?

2011-06-26 Thread dm-list-haskell-cafe
At Sun, 26 Jun 2011 09:31:05 +0100,
Paterson, Ross wrote:
 
 Indeed, the Report has two problems:
 
 Sections 4.4.3.2 and 4.5.5 have different definitions of simple pattern.
 This has been there since section 4.5.5 (Monomorphism Restriction) was
 added in Haskell 1.1.  But then the only technical use of the term is
 in section 4.5.5.

 When the definition of declaration group (section 4.5.1) was changed in
 Haskell 2010 to break dependencies on type signatures, Rule 1 of the
 Monomorphism Restriction (section 4.5.5), while not incorrect, became
 partially redundant and overly complex.  It could have been simplified
 along the lines you describe.

Aha!  This is starting to make sense!  Indeed the Haskell98 text is
far clearer, and when I look at the differences in section 4.5.1, I
start to understand what the committee meant.  Still, the clause

b1 contains a free identifier that has no type signature and
is bound by b2

applies the phrase has no type signature to the identifier, not to
the binding.  Such phrasing does not exclude expression
type-signatures.  I presume that in the following code, binding b1
does not depend on b2:

(x, y) = (z, 1)  -- call this binding b1
(z, _) = (2, y)  -- call this binding b2
w = 1 + (z :: Double)

So my reading was that they meant has no type signature *in b1*.
I take it that your reading is that they meant:

b1 contains a free identifier that is bound by b2 and b2 is
accompanied by a type signature for that identifier

I think, given the ambiguities here, it's worth filing a ticket on the
haskell' web site.

Thank you.
David

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


Re: [Haskell-cafe] What is a simple pattern binding?

2011-06-26 Thread Paterson, Ross
 Still, the clause

 b1 contains a free identifier that has no type signature and
 is bound by b2

 applies the phrase has no type signature to the identifier, not to
 the binding.  Such phrasing does not exclude expression
 type-signatures.

True.  That ambiguity could be avoided by adding the word declaration
after type signature.

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


Re: [Haskell-cafe] What is a simple pattern binding?

2011-06-26 Thread Paterson, Ross
  Still, the clause
 
  b1 contains a free identifier that has no type signature and
  is bound by b2
 
  applies the phrase has no type signature to the identifier, not to
  the binding.  Such phrasing does not exclude expression
  type-signatures.
 
 True.  That ambiguity could be avoided by adding the word declaration
 after type signature.

On second thoughts, this is unnecessary.  The Report consistently uses
expression type signature for the expression and type signature
for the declaration.

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


[Haskell-cafe] Data.Enumerator.List.concatMap is to Data.Iteratee.?

2011-06-26 Thread David Place
Hi:

I've been studying iteratee IO.  Is there a function in the iteratee package  
that is analogous to Data.Enumerator.List.concatMap?


David Place   
Owner, Panpipes Ho! LLC
http://panpipesho.com
d...@vidplace.com




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


Re: [Haskell-cafe] What is a simple pattern binding?

2011-06-26 Thread dm-list-haskell-cafe
At Sun, 26 Jun 2011 21:15:06 +0100,
Paterson, Ross wrote:
 
  True.  That ambiguity could be avoided by adding the word declaration
  after type signature.
 
 On second thoughts, this is unnecessary.  The Report consistently uses
 expression type signature for the expression and type signature
 for the declaration.

I already sent the haskell-prime mailing list a proposal for the
following wording:

A binding b1 depends on a binding b2 in the same list of
declarations if either

1. b1 contains a free identifier v, v is bound by b2, and the
   list of declarations does not contain a type signature for
   v; or

http://www.haskell.org/pipermail/haskell-prime/2011-June/003482.html

I think this is clearer, but it might make more sense to discuss on
haskell-prime.

David

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


Re: [Haskell-cafe] Alex Lexer Performance Issues

2011-06-26 Thread Richard O'Keefe

On 26/06/2011, at 10:19 PM, Malcolm Wallace wrote:
 There is an old folklore that lexing is usually the most expensive phase of 
 any compiler-like traversal.  50% of time and space expended on lexing was 
 pretty common twenty years ago.

Indeed it is old, but no, it isn't folklore, you'll find actual measurements in 
Per Brinch Hansen,
and no, what was pretty common twenty years ago is not necessarily valid today.

Depending on what you are compiling into what, you could be spending a lot of 
time reading,
a lot of time writing, or a lot of time doing semantic analysis and 
optimisation.  For
example, lexing C++ is clearly a linear time operation, but type checking C++ 
is Turing
complete (any computable function can be expressed as a C++ type checking 
problem).
There's a Scheme compiler I know of where semantic analysis is at least 
O(N**3), N being
the number of nodes in the AST.

Also, much depends on the level at which you are doing I/O.  Stuff layered on 
top of C stdio
can be amazingly slow (thanks in part to libraries that acquire and release a 
lock for 
every call to getc() or putc()).


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


[Haskell-cafe] View Thunk Evaluation

2011-06-26 Thread Tom Murphy
Hi All,
 Is there a way to determine whether a thunk was evaluated during
code's execution?

Thanks,
Tom

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


Re: [Haskell-cafe] View Thunk Evaluation

2011-06-26 Thread Don Stewart
Yes, via the -hpc tracing mechanism.

When executed HPC generates a highlighted log of your source, and
expressions that aren't evaluated will be marked up in a special
color.

On Sun, Jun 26, 2011 at 9:22 PM, Tom Murphy amin...@gmail.com wrote:
 Hi All,
     Is there a way to determine whether a thunk was evaluated during
 code's execution?

 Thanks,
 Tom

 ___
 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] Trouble with `foldl` in composition chain.

2011-06-26 Thread David Banas
When profiling this code:

consolidateRPR :: [Sample] - [Sample]

smplUnionRecursRev :: [Sample] - Sample - [Sample]

sortSamps :: [Sample] - [Sample]

smplSetUnion :: [Sample] - [Sample]
smplSetUnion = consolidateRPR . (foldl smplUnionRecursRev []) . 
sortSamps

I'm getting this:

smplSetUnion   Data.RandProc   
1038   32794   0.70.276.9   72.6
 consolidateRPRData.RandProc   
1041   32794   0.00.0 8.2   11.8
 smplUnionRecursRev Data.RandProc   
1040  918112   8.85.6 8.85.6
 sortSamps Data.RandProc   
1039 1081514  21.1   55.059.2   55.0

I'm confused as to why `sortSamps` is being called so many times. I
would expect it to be called 32794 times, just like `consolidateRPR`.
It's as if having a `foldl` to the left of `sortSamps` in the
composition chain is causing it to execute more than once, per call of
`smplSetUnion`, but I wouldn't expect that.

This doesn't change anything:

smplSetUnion = consolidateRPR . (\ss - foldl smplUnionRecursRev [] ss) 
. sortSamps

(I thought it might explicitly close the `foldl`.)

In fact, even this:

smplSetUnion ss = consolidateRPR $ foldl smplUnionRecursRev [] ss'
where ss' = sortSamps ss

doesn't change anything. `sortSamps` still gets entered 1081514 times!

Can anyone help clear up this newbie's fog?

Thanks, in advance!
-db



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