Re: [Haskell-cafe] need help with understanding expression

2012-11-16 Thread Daryoush Mehrtash
Yes, same problem, and again I have no idea how to read the type

Prelude :t max. 3 2
max. 3 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b


What does the type mean in plain english?

Daryoush

On Thu, Nov 15, 2012 at 11:56 PM, Ramana Kumar ramana.ku...@cl.cam.ac.ukwrote:

 Another experiment may be revealing:

 :t 3 2



 On Fri, Nov 16, 2012 at 7:46 AM, Daryoush Mehrtash dmehrt...@gmail.comwrote:

 I see the point with :t (.)  that

 max.(+1) 2 2

 is the same as

 max. 3 2

 Which is not what I want.

 But I have no idea what the type signature of this expression mean now

 Prelude :t max. 3 2
 max. 3 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b

 Any idea?

 Daryoush


 On Thu, Nov 15, 2012 at 11:19 PM, Ramana Kumar ramana.ku...@cl.cam.ac.uk
  wrote:

 Hi Daryoush,

 I recommend you try these experiments first, and then reply back if
 you're still confused.

 :t max

 :t (+1)

 :t max . (+1)

 :t (+1) 2

 :t (.)


 On Fri, Nov 16, 2012 at 7:10 AM, Daryoush Mehrtash 
 dmehrt...@gmail.comwrote:

 I am having hard time understanding how removing the
  outer parenthesis in

 (max.(+1)) 2 2

 to

 max.(+1) 2 2

 changes the meaning of expression.

 My expectation was that max.(+1) takes two numbers and returns the max
 as defined in the type:

 :t max.(+1)
 max.(+1) :: (Ord b, Num b) = b - b - b



 With parenthesis it does what I expect it to:


 Prelude :t (max.(+1)) 2 2
 (max.(+1)) 2 2 :: (Ord b, Num b) = b
 Prelude  (max.(+1)) 2 2
 3


 But if I remove the parenthesis I get a beast that I have no idea what
 its type signature mean any more

 Prelude :t (max.(+1)) 2 2
 (max.(+1)) 2 2 :: (Ord b, Num b) = b
 Prelude :t max.(+1) 2 2
 max.(+1) 2 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b


 How did removal of parenthesis changed the meaning?  How do you
 interpret the type:  (Ord b, Num a1, Num (a1 - a - b)) = a - b - b?

 Thanks



 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/

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





 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/





-- 
Daryoush

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


Re: [Haskell-cafe] need help with understanding expression

2012-11-16 Thread Daryoush Mehrtash
Sorry wrong paste

Prelude :t 3 2
3 2 :: (Num a, Num (a - t)) = t


What does the type mean in plain english?

Daryoush

On Fri, Nov 16, 2012 at 12:00 AM, Daryoush Mehrtash dmehrt...@gmail.comwrote:

 Yes, same problem, and again I have no idea how to read the type

 Prelude :t max. 3 2
 max. 3 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b


 What does the type mean in plain english?

 Daryoush

 On Thu, Nov 15, 2012 at 11:56 PM, Ramana Kumar 
 ramana.ku...@cl.cam.ac.ukwrote:

 Another experiment may be revealing:

 :t 3 2



 On Fri, Nov 16, 2012 at 7:46 AM, Daryoush Mehrtash 
 dmehrt...@gmail.comwrote:

 I see the point with :t (.)  that

 max.(+1) 2 2

 is the same as

 max. 3 2

 Which is not what I want.

 But I have no idea what the type signature of this expression mean now

 Prelude :t max. 3 2
 max. 3 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b

 Any idea?

 Daryoush


 On Thu, Nov 15, 2012 at 11:19 PM, Ramana Kumar 
 ramana.ku...@cl.cam.ac.uk wrote:

 Hi Daryoush,

 I recommend you try these experiments first, and then reply back if
 you're still confused.

 :t max

 :t (+1)

 :t max . (+1)

 :t (+1) 2

 :t (.)


 On Fri, Nov 16, 2012 at 7:10 AM, Daryoush Mehrtash dmehrt...@gmail.com
  wrote:

 I am having hard time understanding how removing the
  outer parenthesis in

 (max.(+1)) 2 2

 to

 max.(+1) 2 2

 changes the meaning of expression.

 My expectation was that max.(+1) takes two numbers and returns the
 max as defined in the type:

 :t max.(+1)
 max.(+1) :: (Ord b, Num b) = b - b - b



 With parenthesis it does what I expect it to:


 Prelude :t (max.(+1)) 2 2
 (max.(+1)) 2 2 :: (Ord b, Num b) = b
 Prelude  (max.(+1)) 2 2
 3


 But if I remove the parenthesis I get a beast that I have no idea what
 its type signature mean any more

 Prelude :t (max.(+1)) 2 2
 (max.(+1)) 2 2 :: (Ord b, Num b) = b
 Prelude :t max.(+1) 2 2
 max.(+1) 2 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b


 How did removal of parenthesis changed the meaning?  How do you
 interpret the type:  (Ord b, Num a1, Num (a1 - a - b)) = a - b - b?

 Thanks



 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/

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





 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/





 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/




-- 
Daryoush

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


Re: [Haskell-cafe] need help with understanding expression

2012-11-16 Thread Ramana Kumar
On Fri, Nov 16, 2012 at 8:00 AM, Daryoush Mehrtash dmehrt...@gmail.comwrote:

 Sorry wrong paste

 Prelude :t 3 2
 3 2 :: (Num a, Num (a - t)) = t


It means that 2 has type a (which must be in the Num class), 3 has type (a
- t) (which also must be in the Num class), and the type of (3 2) is
therefore t.
When you apply one expression to another, the first must have function
type, and the second must have the type of the domain of the function,
hence the a - t and a.
Furthermore, the numeric literals are always interpreted as being in the
Num class.
I haven't been able to find any good introduction to numeric literals and
the Num class with quick search, so if anyone else on list can point us to
one (if it exists) that would be great.




 What does the type mean in plain english?

 Daryoush

 On Fri, Nov 16, 2012 at 12:00 AM, Daryoush Mehrtash 
 dmehrt...@gmail.comwrote:

 Yes, same problem, and again I have no idea how to read the type

 Prelude :t max. 3 2
 max. 3 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b


 What does the type mean in plain english?

 Daryoush

 On Thu, Nov 15, 2012 at 11:56 PM, Ramana Kumar ramana.ku...@cl.cam.ac.uk
  wrote:

 Another experiment may be revealing:

 :t 3 2



 On Fri, Nov 16, 2012 at 7:46 AM, Daryoush Mehrtash 
 dmehrt...@gmail.comwrote:

 I see the point with :t (.)  that

 max.(+1) 2 2

 is the same as

 max. 3 2

 Which is not what I want.

 But I have no idea what the type signature of this expression mean now

 Prelude :t max. 3 2
 max. 3 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b

 Any idea?

 Daryoush


 On Thu, Nov 15, 2012 at 11:19 PM, Ramana Kumar 
 ramana.ku...@cl.cam.ac.uk wrote:

 Hi Daryoush,

 I recommend you try these experiments first, and then reply back if
 you're still confused.

 :t max

 :t (+1)

 :t max . (+1)

 :t (+1) 2

 :t (.)


 On Fri, Nov 16, 2012 at 7:10 AM, Daryoush Mehrtash 
 dmehrt...@gmail.com wrote:

 I am having hard time understanding how removing the
  outer parenthesis in

 (max.(+1)) 2 2

 to

 max.(+1) 2 2

 changes the meaning of expression.

 My expectation was that max.(+1) takes two numbers and returns the
 max as defined in the type:

 :t max.(+1)
 max.(+1) :: (Ord b, Num b) = b - b - b



 With parenthesis it does what I expect it to:


 Prelude :t (max.(+1)) 2 2
 (max.(+1)) 2 2 :: (Ord b, Num b) = b
 Prelude  (max.(+1)) 2 2
 3


 But if I remove the parenthesis I get a beast that I have no idea
 what its type signature mean any more

 Prelude :t (max.(+1)) 2 2
 (max.(+1)) 2 2 :: (Ord b, Num b) = b
 Prelude :t max.(+1) 2 2
 max.(+1) 2 2 :: (Ord b, Num a1, Num (a1 - a - b)) = a - b - b


 How did removal of parenthesis changed the meaning?  How do you
 interpret the type:  (Ord b, Num a1, Num (a1 - a - b)) = a - b - 
 b?

 Thanks



 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/

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





 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/





 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/




 --
 Daryoush

 Weblog:  http://onfp.blogspot.com/

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


Re: [Haskell-cafe] need help with understanding expression

2012-11-16 Thread Sean Leather
Hi Daryoush,

Prelude :t 3 2
 3 2 :: (Num a, Num (a - t)) = t

 What does the type mean in plain english?


It's important to remember that numeric literals are polymorphic. That is,
3 :: Num a = a. They do not have monomorphic types such as Int or Integer.

In the above, GHCi is inferring the principal type of 3 applied to 2. Since
3 is in the position of function application, it should have a function
type, e.g. a - t. And 2 is the argument to 3, so it has the type 'a'. But
there must be Num constraints on these types, and that's what the
context (Num a, Num (a - t)) is telling you. Num (a - t) is a strange
constraint but so is applying 3 to 2. Whenever you see a Num constraint on
a function type, it probably means you're doing something wrong.

You might find the (brief) description of typing numeric literals in the
language definition helpful:

http://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1360006.4.1

Also, in response to your initial query...

I am having hard time understanding how removing the  outer parenthesis in
 (max.(+1)) 2 2
 to
 max.(+1) 2 2


Keep in mind the precedence of the function composition operator (.) here:

Prelude :i (.)
(.) :: (b - c) - (a - b) - a - c -- Defined in GHC.Base
infixr 9 .

Function application is infixl 10, so even though max . (+1) :: (Num b, Ord
b) = b - b - b, when you do max . (+1) 2, the application of (+1) to 2
binds more tightly than (.).

A common idiom for removing parentheses with a sequence of compositions is
to use ($):

Prelude :i ($)
($) :: (a - b) - a - b -- Defined in GHC.Base
infixr 0 $

Note that it has the lowest possible precedence. So, you often see the
composition of functions as f . g . h $ arg. But this doesn't work well
for (curried) functions with 2 arguments. So, in your case, I'd guess the
parentheses is simplest idiomatic solution. Though, I think I'd prefer max
(succ 2) 2.

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


Re: [Haskell-cafe] I killed performance of my code with Eval and Strategies

2012-11-16 Thread Dmitry Olshansky
Just another definition of calculateSeq:

calculateSeq = zipWith ($) (cycle [sin,cos]) . map sqrt


2012/11/15 Janek S. fremenz...@poczta.onet.pl

  Do you really mean to calculate the 'sin . sqrt' of just the head of the
 list, or do you mean:
  calculateSeq = map (sin . sqrt)   ?
 Argh.. of course not! That's what you get when you code in the middle of a
 night. But in my code I
 will not be able to use map because elements will be processed in pairs,
 so let's say that my
 sequential function looks like this:

 calculateSeq :: [Double] - [Double]
 calculateSeq [] = []
 calculateSeq [x] = [sin . sqrt $ x]
 calculateSeq (x:y:xs) = (sin . sqrt $ x) : (cos . sqrt $ y) : calculateSeq
 xs

  I don't think there's a memory leak. It looks more like you're just
  allocating much more than is sane for such a simple function.
  On a recent processor, sin . sqrt is two instructions. Meanwhile, you
 have
  a list of (boxed?) integers being split up, then recombined. That's bound
  to hurt the GC.
 I am not entirely convinced that my idea of using eval+strategies is bound
 to be slow, because
 there are functions like parListChunk that do exactly this: split the list
 into chunks, process
 them in parallel and then concatenate the result. Functions in
 Control.Parallel.Strategies were
 designed to deal with list so I assume it is possible to process lists in
 parallel without GC
 problems. However I do not see a way to apply these functions in my
 setting where elements of
 lists are processed in pairs, not one at a time (parList and parMap will
 not do). Also, working
 on a list of tuples will not do.

  Also, you might want to configure criterion to GC between
  runs. That might help.
 The -g flag passed to criterion executable does that.

  What I'd suggest doing instead, is breaking the input into chucks of,
 say,
  1024, and representing it with a [Vector]. Then, run your sin.sqrt's on
  each vector in parallel. Finally, use Data.Vector.concat to combine your
  result.
 As stated in my post scriptum I am aware of that solution :) Here I'm
 trying to figure what am I
 doing wrong with Eval.

 Thanks!
 Janek

 
  Hope that helps,
- Clark
 
  On Wed, Nov 14, 2012 at 4:43 PM, Janek S. fremenz...@poczta.onet.pl
 wrote:
   Dear Haskellers,
  
   I am reading Simon Marlow's tutorial on parallelism and I have problems
   with correctly using Eval
   monad and Strategies. I *thought* I understand them but after writing
   some code it turns out that
   obviously I don't because parallelized code is about 20 times slower.
   Here's a short example
   (code + criterion benchmarks):
  
   {-# LANGUAGE BangPatterns #-}
   module Main where
  
   import Control.Parallel.Strategies
   import Criterion.Main
  
   main :: IO ()
   main = defaultMain [
   bench Seq $ nf calculateSeq xs
 , bench Par $ nf calculatePar xs ]
   where xs = [1..16384]
  
   calculateSeq :: [Double] - [Double]
   calculateSeq [] = []
   calculateSeq (x:xs) = (sin . sqrt $ x) : xs
  
   calculatePar :: [Double] - [Double]
   calculatePar xss = runEval $ go xss
   where
 go :: Strategy [Double]
 go [] = return []
 go xs = do
 lsh - (rpar `dot` rdeepseq) $ calculateSeq as
 lst - go bs
 return (lsh ++ lst)
 where
   !(as, bs) = splitAt 8192 xs
  
   Compiling and running with:
  
   ghc -O2 -Wall -threaded -rtsopts -fforce-recomp -eventlog evalleak.hs
   ./evalleak -oreport.html -g +RTS -N2 -ls -s
  
   I get:
  
   benchmarking Seq
   mean: 100.5990 us, lb 100.1937 us, ub 101.1521 us, ci 0.950
   std dev: 2.395003 us, lb 1.860923 us, ub 3.169562 us, ci 0.950
  
   benchmarking Par
   mean: 2.233127 ms, lb 2.169669 ms, ub 2.296155 ms, ci 0.950
   std dev: 323.5201 us, lb 310.2844 us, ub 344.8252 us, ci 0.950
  
   That's a hopeless result. Looking at the spark allocation everything
   looks fine:
  
   SPARKS: 202 (202 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled)
  
   But analyzing eventlog with ThreadScope I see that parallel function
   spends most of the time doing
   garbage collection, which suggests that I have a memory leak
 somewhere. I
   suspected that problem
   might be caused by appending two lists together in the parallel
   implementation, but replacing
   this with difference lists doesn't help. Changing granularity (e.g.
   splitAt 512) also brings no
   improvement. Can anyone point me to what am I doing wrong?
  
   Janek
  
   PS. This is of course not a real world code - I know that I'd be better
   of using unboxed data
   structures for doing computations on Doubles.
  
   ___
   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] How to determine correct dependency versions for a library?

2012-11-16 Thread Ketil Malde
Aleksey Khudyakov alexey.sklad...@gmail.com writes:

 Adding more restrictive constraints does not work, the broken package will
 be on hackage forever, while adding a new version with relaxed constraints
 works well.

 That illustrate real problem It's not possible to specify correct
 version constraints when package is uploaded. So one have to choose
 between optimistic and conservative approach. Both have disadvantages.
 In ideal world one need ability to adjust version bounds after package
 upload.

+1. Metadata (i.e. the cabal file) chould be editable.  In addition to
adjusting dependency bounds, Hackage (or third party build servers)
could add Tested-With, and there could be a deprecated field added when
problems are discovered.

-k

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


Re: [Haskell-cafe] How to determine correct dependency versions for a library?

2012-11-16 Thread Peter Simons
Hi Tobias,

  A 1.1.4.0 build-depends: B ==2.5.* C ==3.7.* (overspecified)
  B 2.5.3.0 build-depends: C ==3.* (underspecified)
  C 3.7.1.0
 
  Everything works nice until C-3.8.0.0 appears with incompatible changes
  that break B, but not A.
 
  Now both A and B have to update their dependencies and we have now:
 
  A 1.1.5.0 build-depends: B ==2.5.* C =3.7  3.9
  B 2.5.4.0 build-depends: C =3  3.8
  C 3.8.0.0
 
  And now the following combination is still valid:
  A 1.1.5.0
  B 2.5.3.0 (old version)
  C 3.8.0.0
  Bang!

thank you for contributing this insightful example.

When such a situation has arisen in the past, it's my experience that the
author of B typically releases an update to fix the issue with the latest
version of C:

  B 2.5.4.0 build-depends: C = 3.8

So that particular conflict does hardly ever occur in practice.

Note that package A would build just fine after that update of B -- if the
author of A hadn't overspecified its dependencies. As it is, however, a
new version of A has to released that changes no code, but only the Cabal
file.

Take care,
Peter


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


Re: [Haskell-cafe] Taking over ghc-core

2012-11-16 Thread Carter Schonwald
how would ghc-core enable targetting core for Agda?


On Wed, Nov 14, 2012 at 6:32 PM, Andreas Abel andreas.a...@ifi.lmu.dewrote:

 Excellent!

 With ghc-core being maintained again, we can start thinking about
 compiling Agda to core instead of hs.

 Andreas


 On 11.11.12 11:41 AM, Bas van Dijk wrote:

 Great!

 On 10 November 2012 16:17, Shachaf Ben-Kiki shac...@gmail.com wrote:

 With Don Stewart's blessing
 (https://twitter.com/donsbot/**status/267060717843279872https://twitter.com/donsbot/status/267060717843279872),
 I'll be
 taking over maintainership of ghc-core, which hasn't been updated
 since 2010. I'll release a version with support for GHC 7.6 later
 today.

  Shachaf


 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe


 --
 Andreas AbelDu bist der geliebte Mensch.

 Theoretical Computer Science, University of Munich
 Oettingenstr. 67, D-80538 Munich, GERMANY

 andreas.a...@ifi.lmu.de
 http://www2.tcs.ifi.lmu.de/~**abel/ http://www2.tcs.ifi.lmu.de/~abel/


 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://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] How to determine correct dependency versions for a library?

2012-11-16 Thread Tobias Müller
Peter Simons sim...@cryp.to wrote:
 Hi Tobias,
 
   A 1.1.4.0 build-depends: B ==2.5.* C ==3.7.* (overspecified)
   B 2.5.3.0 build-depends: C ==3.* (underspecified)
   C 3.7.1.0
  
   Everything works nice until C-3.8.0.0 appears with incompatible changes
   that break B, but not A.
  
   Now both A and B have to update their dependencies and we have now:
  
   A 1.1.5.0 build-depends: B ==2.5.* C =3.7  3.9
   B 2.5.4.0 build-depends: C =3  3.8
   C 3.8.0.0
  
   And now the following combination is still valid:
   A 1.1.5.0
   B 2.5.3.0 (old version)
   C 3.8.0.0
   Bang!
 
 thank you for contributing this insightful example.
 
 When such a situation has arisen in the past, it's my experience that the
 author of B typically releases an update to fix the issue with the latest
 version of C:
 
   B 2.5.4.0 build-depends: C = 3.8
 
 So that particular conflict does hardly ever occur in practice.

And what if the maintainer of a takes the chance to make some major updates
and directly releases 2.6? Then all packages depending on 2.5.* will
probably break. 

 Note that package A would build just fine after that update of B -- if the
 author of A hadn't overspecified its dependencies. As it is, however, a
 new version of A has to released that changes no code, but only the Cabal
 file.

But all this boils down to a system where only a combination of latest
versions will be stable. So why restrict dependencies anyway?

Tobi


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


Re: [Haskell-cafe] How to determine correct dependency versions for a library?

2012-11-16 Thread Tobias Müller
Ketil Malde ke...@malde.org wrote:
 Aleksey Khudyakov alexey.sklad...@gmail.com writes:
 
 Adding more restrictive constraints does not work, the broken package will
 be on hackage forever, while adding a new version with relaxed constraints
 works well.
 
 That illustrate real problem It's not possible to specify correct
 version constraints when package is uploaded. So one have to choose
 between optimistic and conservative approach. Both have disadvantages.
 In ideal world one need ability to adjust version bounds after package
 upload.
 
 +1. Metadata (i.e. the cabal file) chould be editable.  In addition to
 adjusting dependency bounds, Hackage (or third party build servers)
 could add Tested-With, and there could be a deprecated field added when
 problems are discovered.

The last version component (D in A.B.C.D) could be considered the metadata
version. Then cabal could be changed to only take into account the highest
D-values.

Alternatively, if the semantics of D cannot be changed, make it A.B.C.D_M
(M for metadata version). That's the way MacPorts handles the problem.

Tobi


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


Re: [Haskell-cafe] need help with understanding expression

2012-11-16 Thread Albert Y. C. Lai

On 12-11-16 02:10 AM, Daryoush Mehrtash wrote:

I am having hard time understanding how removing the  outer parenthesis in

(max.(+1)) 2 2

to

max.(+1) 2 2

changes the meaning of expression.


I recommend http://bm380.user.srcf.net/prettyparsetree.cgi for 
discovering the correct parse.


Specifically,

  max.(+1) 2 2
=  { use uniform spacing to un-presume }
  max . (+1) 2 2
=  { . is lower than application }
  max . ((+1) 2 2)

etc.

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


Re: [Haskell-cafe] Taking over ghc-core

2012-11-16 Thread Jay Sulzberger



On Fri, 16 Nov 2012, Carter Schonwald carter.schonw...@gmail.com wrote:


how would ghc-core enable targetting core for Agda?


On Wed, Nov 14, 2012 at 6:32 PM, Andreas Abel andreas.a...@ifi.lmu.dewrote:


Excellent!

With ghc-core being maintained again, we can start thinking about
compiling Agda to core instead of hs.

Andreas


I would like to be able to take the textual version of Core
output by GHC and use that text as input to the next stage of
compilation.

oo--JS.





On 11.11.12 11:41 AM, Bas van Dijk wrote:


Great!

On 10 November 2012 16:17, Shachaf Ben-Kiki shac...@gmail.com wrote:


With Don Stewart's blessing
(https://twitter.com/donsbot/**status/267060717843279872https://twitter.com/donsbot/status/267060717843279872),
I'll be
taking over maintainership of ghc-core, which hasn't been updated
since 2010. I'll release a version with support for GHC 7.6 later
today.

 Shachaf



__**_
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe



--
Andreas AbelDu bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.a...@ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~**abel/ http://www2.tcs.ifi.lmu.de/~abel/


__**_
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://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] Taking over ghc-core

2012-11-16 Thread Brent Yorgey
On Fri, Nov 16, 2012 at 03:25:35PM -0500, Jay Sulzberger wrote:
 
 
 On Fri, 16 Nov 2012, Carter Schonwald carter.schonw...@gmail.com wrote:
 
 how would ghc-core enable targetting core for Agda?
 
 
 On Wed, Nov 14, 2012 at 6:32 PM, Andreas Abel andreas.a...@ifi.lmu.dewrote:
 
 Excellent!
 
 With ghc-core being maintained again, we can start thinking about
 compiling Agda to core instead of hs.
 
 Andreas
 
 I would like to be able to take the textual version of Core
 output by GHC and use that text as input to the next stage of
 compilation.
 
 oo--JS.

Note that the ghc-core package only does pretty-printing of GHC core.
Whether GHC can parse a textual representation of GHC core (like Jay
and, presumably, Andreas want) is unrelated to the ghc-core package.

-Brent

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


Re: [Haskell-cafe] Taking over ghc-core

2012-11-16 Thread Jay Sulzberger



On Fri, 16 Nov 2012, Brent Yorgey byor...@seas.upenn.edu wrote:


On Fri, Nov 16, 2012 at 03:25:35PM -0500, Jay Sulzberger wrote:



On Fri, 16 Nov 2012, Carter Schonwald carter.schonw...@gmail.com wrote:


how would ghc-core enable targetting core for Agda?


On Wed, Nov 14, 2012 at 6:32 PM, Andreas Abel andreas.a...@ifi.lmu.dewrote:


Excellent!

With ghc-core being maintained again, we can start thinking about
compiling Agda to core instead of hs.

Andreas


I would like to be able to take the textual version of Core
output by GHC and use that text as input to the next stage of
compilation.

oo--JS.


Note that the ghc-core package only does pretty-printing of GHC core.
Whether GHC can parse a textual representation of GHC core (like Jay
and, presumably, Andreas want) is unrelated to the ghc-core package.

-Brent


Thanks, Brent!

My post was based on ignorance.

OK, I would like to suggest a talk at NYHUG on the GHC pipeline.
Else I might look at it without the support of NYHUGgers and
drink.

oo--JS.




___
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] How to determine correct dependency versions for a library?

2012-11-16 Thread Peter Simons
Hi Tobias,

  When such a situation has arisen in the past, it's my experience
  that the author of B typically releases an update to fix the issue
  with the latest version of C:
 
B 2.5.4.0 build-depends: C = 3.8
 
  So that particular conflict does hardly ever occur in practice.
 
  And what if the maintainer of a takes the chance to make some major
  updates and directly releases 2.6? Then all packages depending on
  2.5.* will probably break.

yes, that is true. In such a case, one would have to contact the
maintainer of A, B, and C to discuss how to remedy the issue.
Fortunately, pathological cases such as this one seem to happen rarely
in practice.

  All this boils down to a system where only a combination of latest
  versions will be stable. So why restrict dependencies anyway?

Now, I think that is an exaggeration. Do you know a single example of a
package on Hackage that actually suffers from the problem you're
describing?

Take care,
Peter


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


[Haskell-cafe] Polymorphic Type Safe URL building -- I need advice on my project

2012-11-16 Thread Kyle Hanson
Hello,

So I started working on a project involving polymorphic type safe urls. I
know there are other type-safe url's out there, but I want some advice
before I start reorganizing it.

It is located here: https://github.com/dracule/web-scatter

One might ask why you would want polymorphic types in your URL. Current
implementation of type-safe URLs use a single type and then have it pattern
match on the constructors.

However, It is a pretty common occurrence that you might want to use a type
from other parts of code. Where this becomes prevalent is in IxSet and
AcidState. For IxSet your Index keys all have to have separate types . So
with this, you can convert your url into your index key's type and then
just make your handler like this:

  myHandler :: BlogId - SomeWebHandler

I know my code probably has some terrible inefficiencies or something, so I
am looking for some feedback on some jarring problems.

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


[Haskell-cafe] ANN: hledger-web 0.19

2012-11-16 Thread Simon Michael
I'm pleased to announce hledger-web 0.19, compatible with the latest
hledger and Yesod.

Release notes:

  * web: builds with yesod 1.1.3

  * web: obeys command-line query options at startup again

  * the autogenerated session file is now a dot file
(.hledger-web_client_session.aes)

hledger is a command-line tool and haskell library for tracking
financial transactions, which are stored in a human-readable plain
text format. In addition to reporting, it can also help you record new
transactions, or convert CSV data from your bank. Add-on packages
include hledger-web, a web interface. hledger is inspired by and
compatible with John Wiegley's Ledger. For more, see http://hledger.org
.

Install it:

cabal update; cabal install hledger-web
For more installation help, see
http://hledger.org/MANUAL.html#installing .
Or, sponsor a ready-to-run binary for your platform:
http://hledger.org/DOWNLOAD.html .

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


Re: [Haskell-cafe] need help with understanding expression

2012-11-16 Thread damodar kulkarni
Let's see tthis:
Prelude :t 3 a
3 a :: (Num ([Char] - t)) = t

No complaint from GHC; but now see this:

Prelude :t  a 3

interactive:1:0:
Couldn't match expected type `t1 - t'
   against inferred type `[Char]'
In the expression: a 3

Why does it not fail for  (:t 3 a) but does fail for (:t  a 3)?

In the second case, why the GHC doesn't give something like?
([Char] (a - t), Num a) = t

In other words, how the first one does make sense (however strange the
sense may seem) to GHC while the second one doesn't?

Now let's consider the evaluation scenario:

Prelude  3 2

interactive:1:0:
No instance for (Num (t - t1))
  arising from the literal `3' at interactive:1:0-2
Possible fix: add an instance declaration for (Num (t - t1))
In the expression: 3 2
In the definition of `it': it = 3 2

Note, how the GHC suggests us this strange constraint as a *possible
fix*BUT see this:
Prelude  a 2

interactive:1:0:
Couldn't match expected type `t1 - t'
   against inferred type `[Char]'
In the expression: a 2
In the definition of `it': it = a 2

In this case the GHC doesn't even allow us to add any possible fix.



-Damodar


On Fri, Nov 16, 2012 at 2:27 PM, Sean Leather leat...@cs.uu.nl wrote:

 Hi Daryoush,


 Prelude :t 3 2
 3 2 :: (Num a, Num (a - t)) = t

 What does the type mean in plain english?


 It's important to remember that numeric literals are polymorphic. That is,
 3 :: Num a = a. They do not have monomorphic types such as Int or Integer.

 In the above, GHCi is inferring the principal type of 3 applied to 2.
 Since 3 is in the position of function application, it should have a
 function type, e.g. a - t. And 2 is the argument to 3, so it has the type
 'a'. But there must be Num constraints on these types, and that's what the
 context (Num a, Num (a - t)) is telling you. Num (a - t) is a strange
 constraint but so is applying 3 to 2. Whenever you see a Num constraint on
 a function type, it probably means you're doing something wrong.

 You might find the (brief) description of typing numeric literals in the
 language definition helpful:


 http://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1360006.4.1

 Also, in response to your initial query...

 I am having hard time understanding how removing the  outer parenthesis in
 (max.(+1)) 2 2
 to
 max.(+1) 2 2


 Keep in mind the precedence of the function composition operator (.) here:

 Prelude :i (.)
 (.) :: (b - c) - (a - b) - a - c -- Defined in GHC.Base
 infixr 9 .

 Function application is infixl 10, so even though max . (+1) :: (Num b,
 Ord b) = b - b - b, when you do max . (+1) 2, the application of (+1) to
 2 binds more tightly than (.).

 A common idiom for removing parentheses with a sequence of compositions is
 to use ($):

 Prelude :i ($)
 ($) :: (a - b) - a - b -- Defined in GHC.Base
 infixr 0 $

 Note that it has the lowest possible precedence. So, you often see the
 composition of functions as f . g . h $ arg. But this doesn't work well
 for (curried) functions with 2 arguments. So, in your case, I'd guess the
 parentheses is simplest idiomatic solution. Though, I think I'd prefer max
 (succ 2) 2.

 Regards,
 Sean

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




-- 
Thanks and regards,
-Damodar Kulkarni
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe