Re: [GHC] #5267: Arrow command combinators

2011-06-27 Thread GHC
#5267: Arrow command combinators
+---
  Reporter:  peteg  |  Owner:  
  Type:  bug| Status:  new 
  Priority:  normal |  Milestone:  
 Component:  Compiler   |Version:  7.0.3   
Resolution: |   Keywords:  
  Testcase: |  Blockedby:  
Difficulty: | Os:  Unknown/Multiple
  Blocking: |   Architecture:  Unknown/Multiple
   Failure:  GHC rejects valid program  |  
+---
Changes (by peteg):

 * cc: peteg (added)
  * status:  closed = new
  * resolution:  invalid =


Comment:

 Ross, thanks for the clarification. I was playing golf with code of this
 form:

 {{{
 {-# LANGUAGE Arrows #-}
 module T where

 import Prelude
 import Control.Arrow

 t = proc () -
  do rec x - (| (arr id) (returnA - x) |)
 y - arr id - x
 returnA - y
 }}}

 (for non-trivial arrows) and surprised to get this error. The question was
 whether one can put anything between {{{-}}} and {{{(|}}}, as I did in
 the original bug report.

 My operators tend to be of the form:

 arrAC :: Arrow (~) = (env ~ a) - (env ~ a) - (env ~ a)

 which syntactically doesn't satisfy your requirement but seems to work
 anyway. I get confused by just where the syntactic criteria kick in and
 why.

 In any case can we let this bug stand as a complaint that saying some type
 variable has the wrong shape is a terrible error message? GHC usually
 tells me what it was expecting.

 cheers
 peter

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5267#comment:3
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5272: Performance regression

2011-06-27 Thread GHC
#5272: Performance regression
---+
  Reporter:  augustss  |  Owner:  
  Type:  bug   | Status:  closed  
  Priority:  normal|  Milestone:  
 Component:  Compiler  |Version:  7.0.4   
Resolution:  fixed |   Keywords:  
  Testcase:|  Blockedby:  
Difficulty:| Os:  Unknown/Multiple
  Blocking:|   Architecture:  Unknown/Multiple
   Failure:  None/Unknown  |  
---+

Comment(by simonmar):

 Replying to [comment:4 igloo]:

  I'd be interested to know if the problematic changes were deliberate
 library changes, the new haskell98/base conflict, changes in the more
 experimental GHC extensions, or something else.

 Or the new Unicode support in `withCString`?

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5272#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5275: Data.Typeable not backwards compatible

2011-06-27 Thread GHC
#5275: Data.Typeable not backwards compatible
-+--
Reporter:  augustss  |Owner:  
Type:  bug   |   Status:  new 
Priority:  normal|Milestone:  
   Component:  libraries/base|  Version:  7.1 
Keywords:| Testcase:  
   Blockedby:|   Difficulty:  
  Os:  Unknown/Multiple  | Blocking:  
Architecture:  Unknown/Multiple  |  Failure:  None/Unknown
-+--

Comment(by simonmar):

 I agree.  Is there some reason we use the qualified original name here?
 It's not even necessarily unique, because we don't include the package
 name.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5275#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5269: RTS flag decoding broken

2011-06-27 Thread GHC
#5269: RTS flag decoding broken
-+--
Reporter:  augustss  |   Owner:
Type:  bug   |  Status:  new   
Priority:  normal|   Component:  Runtime System
 Version:  7.0.4 |Keywords:
Testcase:|   Blockedby:
  Os:  Unknown/Multiple  |Blocking:
Architecture:  Unknown/Multiple  | Failure:  None/Unknown  
-+--
Changes (by PHO):

 * cc: pho@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5269#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4211: LLVM: Stack alignment on OSX

2011-06-27 Thread GHC
#4211: LLVM: Stack alignment on OSX
+---
Reporter:  dterei   |Owner:  dterei  
Type:  task |   Status:  new 
Priority:  normal   |Milestone:  7.2.1   
   Component:  Compiler (LLVM)  |  Version:  6.13
Keywords:   | Testcase:  
   Blockedby:   |   Difficulty:  
  Os:  MacOS X  | Blocking:  
Architecture:  x86  |  Failure:  None/Unknown
+---

Comment(by simonmar):

 I'm changing the code that handles stack alignment as a result of #5250, I
 think this change would be easy to make too.  David, ping me if you want
 help with this.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4211#comment:5
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #3910: +RTS options introduce a security problem for, e.g., setuid binaries

2011-06-27 Thread GHC
#3910: +RTS options introduce a security problem for, e.g., setuid binaries
--+-
  Reporter:  andersk  |  Owner:  simonmar
  Type:  bug  | Status:  closed  
  Priority:  normal   |  Milestone:  7.0.2   
 Component:  Runtime System   |Version:  7.1 
Resolution:  fixed|   Keywords:  
  Testcase:   |  Blockedby:  
Difficulty:   | Os:  Unknown/Multiple
  Blocking:   |   Architecture:  Unknown/Multiple
   Failure:  Incorrect result at runtime  |  
--+-

Comment(by simonmar):

 I resent the fact that the broken CGI spec forced the pain of `-rtsopts`
 onto everyone, but we're stuck with it.  Unfortunately most of the RTS
 options are insecure in some sense, whether it is by leaking
 information, DOS, or writing files.

 Just alias `ghc` to `ghc -rtsopts` in your shell, that's what I do.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3910#comment:11
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4459: Polymorphic Data.Dynamic

2011-06-27 Thread GHC
#4459: Polymorphic Data.Dynamic
-+--
Reporter:  vivian|Owner:  vivian
  
Type:  feature request   |   Status:  new   
  
Priority:  normal|Milestone:  7.4.1 
  
   Component:  GHC API   |  Version:  7.1   
  
Keywords:  polymorphic, dynamic, class, linking  | Testcase:
  
   Blockedby:|   Difficulty:
  
  Os:  Unknown/Multiple  | Blocking:  4316  
  
Architecture:  Unknown/Multiple  |  Failure:  
None/Unknown
-+--

Comment(by simonmar):

 I'm completely confused about what this ticket is asking for.  Could
 somebody explain in more detail please?  e.g. the ticket seems to be
 asking for something in the `Data.Dynamic` library, but then there's lots
 of talk about something in the GHC API.  What is `TypedAny`?

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4459#comment:9
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5271: Compilation speed regression

2011-06-27 Thread GHC
#5271: Compilation speed regression
-+--
Reporter:  augustss  |Owner:  
Type:  bug   |   Status:  infoneeded  
Priority:  normal|Milestone:  7.4.1   
   Component:  Compiler  |  Version:  7.0.4   
Keywords:| Testcase:  
   Blockedby:|   Difficulty:  
  Os:  Unknown/Multiple  | Blocking:  
Architecture:  Unknown/Multiple  |  Failure:  Compile-time performance bug
-+--
Changes (by simonmar):

  * status:  new = infoneeded
  * failure:  None/Unknown = Compile-time performance bug
  * milestone:  = 7.4.1


Comment:

 GHC hasn't got uniformly slower at compiling (we do check when making a
 release), but sometime what happens is that some crucial bit of code gets
 inlined where it wasn't before (or vice versa) and that causes knock-on
 effects.

 So to investigate this we'll need more information.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5271#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5269: RTS flag decoding broken

2011-06-27 Thread GHC
#5269: RTS flag decoding broken
-+--
  Reporter:  augustss|  Owner:  
  Type:  bug | Status:  closed  
  Priority:  normal  |  Milestone:  
 Component:  Runtime System  |Version:  7.0.4   
Resolution:  wontfix |   Keywords:  
  Testcase:  |  Blockedby:  
Difficulty:  | Os:  Unknown/Multiple
  Blocking:  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown|  
-+--
Changes (by simonmar):

  * status:  new = closed
  * resolution:  = wontfix


Comment:

 I sympathise.  But the basic problem is that when used as a CGI script,
 the command-line arguments come from an untrusted source, and most people
 wouldn't know that they need to use `-no-rtsopts` with CGI.  Furthermore
 the consequences could be disastrous, so I don't think we had much choice
 here - placing the responsibility on the user to close a security hole
 explicitly with an obscure flag is just wrong.

 See also #3910.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5269#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5262: Compiling with -O makes some expressions too lazy and causes space leaks

2011-06-27 Thread GHC
#5262: Compiling with -O makes some expressions too lazy and causes space leaks
-+--
Reporter:  michal.palka  |Owner:  simonmar  
 
Type:  bug   |   Status:  new   
 
Priority:  normal|Milestone:  7.4.1 
 
   Component:  Compiler  |  Version:  7.1   
 
Keywords:  laziness, strictness, space leak  | Testcase:
 
   Blockedby:|   Difficulty:
 
  Os:  Unknown/Multiple  | Blocking:
 
Architecture:  Unknown/Multiple  |  Failure:  Incorrect 
result at runtime
-+--
Changes (by simonmar):

  * owner:  = simonmar
  * milestone:  = 7.4.1


Comment:

 I'm looking at #5129, and we think the same mechanism can be used to fix
 `seq`, so assigning this to me.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5262#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5276: Multithreaded build failure

2011-06-27 Thread GHC
#5276: Multithreaded build failure
--+-
Reporter:  daniel.is.fischer  |Owner:  benl
Type:  bug|   Status:  new 
Priority:  normal |Milestone:  
   Component:  Build System   |  Version:  7.1 
Keywords: | Testcase:  
   Blockedby: |   Difficulty:  
  Os:  Linux  | Blocking:  
Architecture:  Unknown/Multiple   |  Failure:  None/Unknown
--+-

Comment(by simonmar):

 FWIW, I just saw this on x86/Linux too.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5276#comment:3
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5250: SEGFAULT in FFI to C++ library

2011-06-27 Thread GHC
#5250: SEGFAULT in FFI to C++ library
-+--
  Reporter:  acowley |  Owner:  simonmar
  Type:  bug | Status:  closed  
  Priority:  high|  Milestone:  7.2.1   
 Component:  Compiler (FFI)  |Version:  7.0.3   
Resolution:  fixed   |   Keywords:  
  Testcase:  |  Blockedby:  
Difficulty:  | Os:  Unknown/Multiple
  Blocking:  |   Architecture:  x86 
   Failure:  Runtime crash   |  
-+--
Changes (by simonmar):

  * status:  new = closed
  * resolution:  = fixed


Comment:

 Fixed in e1c9a4f7762009f6cf5db645ee52966eaa979f44 and
 7a4063e9797735da6c490b559c1e89b7d52e4614.

 Thanks for the report!

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5250#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5271: Compilation speed regression

2011-06-27 Thread GHC
#5271: Compilation speed regression
-+--
Reporter:  augustss  |Owner:  
Type:  bug   |   Status:  infoneeded  
Priority:  normal|Milestone:  7.4.1   
   Component:  Compiler  |  Version:  7.0.4   
Keywords:| Testcase:  
   Blockedby:|   Difficulty:  
  Os:  Unknown/Multiple  | Blocking:  
Architecture:  Unknown/Multiple  |  Failure:  Compile-time performance bug
-+--

Comment(by augustss):

 I would think that our compilation is a fairly good benchmark because it
 is about 200,000 lines of Haskell, so it uses all kinds of features.  I
 can't give you the code, so I'm not sure how to provide more information.

 We can let this one rest for now, and we'll check if the regression still
 exists in 7.2.1.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5271#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5272: Performance regression

2011-06-27 Thread GHC
#5272: Performance regression
---+
  Reporter:  augustss  |  Owner:  
  Type:  bug   | Status:  closed  
  Priority:  normal|  Milestone:  
 Component:  Compiler  |Version:  7.0.4   
Resolution:  fixed |   Keywords:  
  Testcase:|  Blockedby:  
Difficulty:| Os:  Unknown/Multiple
  Blocking:|   Architecture:  Unknown/Multiple
   Failure:  None/Unknown  |  
---+

Comment(by augustss):

 First, I don't really mind if ghc is not backwards compatible.
 A compiler has to move forwards and can't support old things forever.
 I just want to point out that every new ghc release is a pain for people
 with a large code base.

 Here are the things that caused pains in porting:

  * haskell98 no longer supported
  * change of type names in Typeable (that took quite a while to debug)
  * Prelude.catch deprecated (we compile with -Werror)
  * network package didn't build using Setup.hs (as usual)
  * glib package didn't build for reasons I never figured out

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5272#comment:7
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #5270: Installing ghc ruins PATH on Windows

2011-06-27 Thread GHC
#5270: Installing ghc ruins PATH on Windows
-+--
Reporter:  augustss  |Owner:  
Type:  bug   |   Status:  infoneeded  
Priority:  normal|Milestone:  
   Component:  None  |  Version:  7.0.4   
Keywords:| Testcase:  
   Blockedby:|   Difficulty:  
  Os:  Windows   | Blocking:  
Architecture:  Unknown/Multiple  |  Failure:  None/Unknown
-+--

Comment(by augustss):

 I didn't try reproducing it.  It's bad enough to have it happen once.

 The corrupted PATH was visible both in the control panel and looking at
 the environment variable in cmd and cygwin.

 I'm not sure how long the path was, I never managed to recover it fully.
 Not overly long, maybe 1k.

 I was installing to the default location.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5270#comment:3
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #5281: Bad compiler warning

2011-06-27 Thread GHC
#5281: Bad compiler warning
-+--
Reporter:  augustss  |   Owner:  
Type:  bug   |  Status:  new 
Priority:  normal|   Component:  Compiler
 Version:  7.1   |Keywords:  
Testcase:|   Blockedby:  
  Os:  Unknown/Multiple  |Blocking:  
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
-+--
 In a jumble of messages from lots of parallel invocations of ghc I see
 this message:
 {{{
 Implicit import declaration:
 Warning: In the use of `catch'
  (imported from Prelude, but defined in System.IO.Error):
  Deprecated: Please use the new exceptions variant,
 Control.Exception.catch
 }}}
 That's nice, but what module did this message come from?

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5281
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4102: Bit manipulation built-ins

2011-06-27 Thread GHC
#4102: Bit manipulation built-ins
-+--
Reporter:  uzytkownik|Owner:  
Type:  feature request   |   Status:  new 
Priority:  normal|Milestone:  7.4.1   
   Component:  libraries/base|  Version:  6.12.2  
Keywords:| Testcase:  
   Blockedby:|   Difficulty:  
  Os:  Unknown/Multiple  | Blocking:  
Architecture:  Unknown/Multiple  |  Failure:  None/Unknown
-+--
Changes (by rrnewton):

 * cc: rrnewton@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4102#comment:10
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4211: LLVM: Stack alignment on OSX

2011-06-27 Thread GHC
#4211: LLVM: Stack alignment on OSX
+---
Reporter:  dterei   |Owner:  dterei  
Type:  task |   Status:  new 
Priority:  normal   |Milestone:  7.2.1   
   Component:  Compiler (LLVM)  |  Version:  6.13
Keywords:   | Testcase:  
   Blockedby:   |   Difficulty:  
  Os:  MacOS X  | Blocking:  
Architecture:  x86  |  Failure:  None/Unknown
+---

Comment(by dterei):

 Yes that would be great Simon, there shouldn't be any issues now that we
 don't support the registerised C backend. Only concern I can think of with
 this change is there may now be cases where the NCG didn't need to do any
 sp manipulation but now will. (E.g for any C calls the NCG will need to
 fix up alignment by subtracting 12 (or 8 on x64), while in the past if no
 system stack was used the sp was already correctly aligned). I can't see
 this causing any performance regression though.

 If you are happy to just take over this ticket thats great, otherwise just
 point me to what needs to be changed and I'll finish it off. I think when
 I had a very brief go at this ticket ages back the main problem was just
 finding all the locations involved in Sp tracking and manipulation.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4211#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #5282: Bizarre results from -P profiler on OS X

2011-06-27 Thread GHC
#5282: Bizarre results from -P profiler on OS X
---+
Reporter:  bos |   Owner: 
Type:  bug |  Status:  new
Priority:  normal  |   Component:  Runtime System 
 Version:  7.0.3   |Keywords: 
Testcase:  |   Blockedby: 
  Os:  MacOS X |Blocking: 
Architecture:  x86_64 (amd64)  | Failure:  Incorrect result at runtime
---+
 I'm trying to use the profiler to understand the performance of an
 application on OS X. I have a smallish benchmark that prints a lot of
 lines of text to `stdout`, and the numbers reported when I use `+RTS -P`
 are very different from what I see with my eyes.

 The benchmark itself is quite simple:

 https://github.com/mailrank/text-format/blob/master/benchmarks/Simple.hs

 When I run it on the command line, it produces simple enough output:

 {{{
 $ time ./Simple one 50 +RTS -P /dev/null
 50 iterations in 2.6 secs (191.7 thousand/sec)

 real0m2.626s
 user0m2.586s
 sys 0m0.030s
 }}}

 The time measured within the app and the wallclock time are both in
 agreement.

 However, if I look at the `Simple.prof` file left behind afterwards, its
 numbers seem bizarre:

 {{{
 Mon Jun 27 11:35 2011 Time and Allocation Profiling Report
 (Final)

Simple +RTS -P -RTS one 50

 total time  =0.28 secs   (14 ticks @ 20 ms)
 total alloc = 2,200,395,720 bytes  (excludes profiling overheads)
 }}}

 It reports a time of just 0.28 seconds, and the number of ticks it counts
 arithmetically agree with this.

 I have other programs that suffer from the same discrepancy between
 wallclock measurement and what the profiler reports to me, such that I
 don't feel like I can trust the profiler at all here. I'm at a loss for
 what to do about this, though.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5282
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4310: Deferred equalities and forall types

2011-06-27 Thread GHC
#4310: Deferred equalities and forall types
-+--
Reporter:  simonpj   |Owner:  simonpj 
Type:  bug   |   Status:  new 
Priority:  normal|Milestone:  7.4.1   
   Component:  Compiler  |  Version:  6.12.3  
Keywords:| Testcase:  
   Blockedby:|   Difficulty:  
  Os:  Unknown/Multiple  | Blocking:  
Architecture:  Unknown/Multiple  |  Failure:  None/Unknown
-+--
Changes (by CoreyOConnor):

 * cc: coreyoconnor@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4310#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4370: Bring back monad comprehensions

2011-06-27 Thread GHC
#4370: Bring back monad comprehensions
--+-
  Reporter:  simonpj  |  Owner:  nsch
  Type:  feature request  | Status:  closed  
  Priority:  normal   |  Milestone:  7.4.1   
 Component:  Compiler |Version:  6.12.3  
Resolution:  fixed|   Keywords:  
  Testcase:   |  Blockedby:  
Difficulty:   | Os:  Unknown/Multiple
  Blocking:   |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown |  
--+-

Comment(by nsch):

 Sorry for the late reply. Yes that sounds pretty good. :)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4370#comment:60
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #5283: Arrow command combinators: addTickHsExpr explodes in GHCi

2011-06-27 Thread GHC
#5283: Arrow command combinators: addTickHsExpr explodes in GHCi
-+--
Reporter:  peteg |   Owner:
Type:  bug   |  Status:  new   
Priority:  normal|   Component:  Compiler  
 Version:  7.0.3 |Keywords:
Testcase:|   Blockedby:
  Os:  Unknown/Multiple  |Blocking:
Architecture:  Unknown/Multiple  | Failure:  Compile-time crash
-+--
 This code:

 {{{
 {-# LANGUAGE Arrows #-}
 module T where

 import Prelude
 import Control.Arrow

 mapAC :: Arrow arr = Integer - arr (env, b) c - arr (env, [b]) [c]
 mapAC n farr = go 1
   where
 go i | i == succ n = arr (\(_env, []) - [])
  | otherwise = proc ~(env, b : bs) -
  do c  - farr - (env, b)
 cs - go (succ i) - (env, bs)
 returnA - c : cs

 t :: Arrow arr = arr [a] [a]
 t = proc ys -
  (| (mapAC 3) (\y - returnA - y) |) ys
 }}}

 compiles fine using GHC. In GHCi I get:

 {{{
 ghc: panic! (the 'impossible' happened)
   (GHC version 7.0.3 for i386-apple-darwin):
 addTickHsExpr
 (|/\(@ a{tv ar3} [sk]).
   ((main:T.mapAC{v rdR} [lid]) @ arr{tv aqZ} [sk] @ a{tv ar3} [sk]
@ a{tv ar0} [sk]
@ a{tv ar0} [sk]
  $dArrow{v ar4} [lid]
  3 (3))
 ((\ ((y{v ajL} [lid] :: a{tv ar0} [sk]))
 - {18:26-37}
(base:Control.Arrow.returnA{v rdx} [gid]) @ arr{tv aqZ}
 [sk]
@ a{tv ar0} [sk]
  $dArrow{v ar5} [lid] - y{v ajL} [lid]))|)
 }}}

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/5283
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4102: Bit manipulation built-ins

2011-06-27 Thread GHC
#4102: Bit manipulation built-ins
-+--
Reporter:  uzytkownik|Owner:  
Type:  feature request   |   Status:  new 
Priority:  normal|Milestone:  7.4.1   
   Component:  libraries/base|  Version:  6.12.2  
Keywords:| Testcase:  
   Blockedby:|   Difficulty:  
  Os:  Unknown/Multiple  | Blocking:  
Architecture:  Unknown/Multiple  |  Failure:  None/Unknown
-+--
Changes (by WrenThornton):

 * cc: wren@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4102#comment:11
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #4459: Polymorphic Data.Dynamic

2011-06-27 Thread GHC
#4459: Polymorphic Data.Dynamic
-+--
Reporter:  vivian|Owner:  vivian
  
Type:  feature request   |   Status:  new   
  
Priority:  normal|Milestone:  7.4.1 
  
   Component:  GHC API   |  Version:  7.1   
  
Keywords:  polymorphic, dynamic, class, linking  | Testcase:
  
   Blockedby:|   Difficulty:
  
  Os:  Unknown/Multiple  | Blocking:  4316  
  
Architecture:  Unknown/Multiple  |  Failure:  
None/Unknown
-+--

Comment(by vivian):

 Replying to [comment:9 simonmar]:
  I'm completely confused about what this ticket is asking for.  Could
 somebody explain in more detail please?  e.g. the ticket seems to be
 asking for something in the `Data.Dynamic` library, but then there's lots
 of talk about something in the GHC API.  What is `TypedAny`?

 This ticket is about adding support for polymorphic dynamic types, which
 would appear in `Data.Dynamic` or similar as a package, so that, for
 example, a variable `sort :: Ord a = [a] - [a]` can be loaded at runtime
 (like `System.Plugins`) and then dynamically linked/typechecked against
 the variable to which it is applied.  Currently dynamics and plugins are
 limited by the monomorphic restriction.

 `TypedAny` (renamed to `DynamicHValue`) is supposed to be an opaque type
 that wraps an `HValue` and a `Type` via the GHC API.  [I have got this
 far, i.e. dynamically loaded code via GHC]

 [In an early incarnation I was able to apply a dynamically loaded ad hoc
 polymorphic function to a list and print the result]

 I listed this as a feature request against the GHC API because there need
 to be some additions 'under the hood' for this to work:

   1) a way of getting the type of an expression to the value level
 `ty - GHC.modInfoLookupName` -- okay for dynamically loaded code but not
 normal code

   2) a way of getting a 'type as value' to become the type of an
 expression
 `(unsafeCoerce hvalue) :: ty` -- currently completely impossible

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4459#comment:10
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: Hoopl: Combining CheckingFuelMonad with State?

2011-06-27 Thread Justin Bailey
I asked this question on StackOverflow and someone suggested using
StateT. Unfortunately I don't think I can really carry around the
state I'd like to:

  
http://stackoverflow.com/questions/6495320/hoopl-how-can-i-combine-the-checkingfuelmonad-with-a-state-monad



On Fri, Jun 24, 2011 at 5:56 PM, Antoine Latter aslat...@gmail.com wrote:
 Hi Justin, this message might be better on the haskell-cafe list (or
 the excellent beginers list!).

 When you tried to write the get/put implementations, what problems
 were you running into?

 Antoine

 On Sat, Jun 25, 2011 at 7:50 AM, Justin Bailey jgbai...@gmail.com wrote:
 I'd like to carry around some state when rewriting. It seems like
 CheckingFuelMonad, etc. are set up to use with other monads but I
 can't get the types to agree.

 Using MTL I've managed to come up with these types:

 newtype RewriteOnce a = R (State Bool a)
   deriving (Monad)

 instance MonadState s (CheckingFuelMonad RewriteOnce) where
   get = undefined
   put = undefined


 But I cannot write the definitions for get and put. Is this possible
 or am I misundersanding CheckingFuelMonad? Is there a better approach
 altogether?

 Thanks in advance for any help!

 Justin

 ___
 Glasgow-haskell-users mailing list
 Glasgow-haskell-users@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell] ANNOUNCE: release v0.2 of RandProc library

2011-06-27 Thread David Banas
v0.2 of the `RandProc` library has been released to HackageDB.
http://hackage.haskell.org/package/randproc

Changes in this release:

  * Improved several severe performance bottlenecks. (The `goodDie`
space can now actually be checked, without exhausting
memory/time.)
  * Cleaned up the code, as per `hlint` suggestions.


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


[Haskell] CFP PEPM12: Workshop on Partial Evaluation and Program Manipulation

2011-06-27 Thread oleg

ACM SIGPLAN 2012 Workshop on Partial Evaluation and Program Manipulation
January 23-24, 2012. Philadelphia, Pennsylvania, USA (co-located with POPL'12)

Call For Papers

http://www.program-transformation.org/PEPM12

The PEPM Symposium/Workshop series aims to bring together researchers and
practitioners working in the broad area of principled program transformation,
which spans from refactoring, partial evaluation, supercompilation, fusion and
other metaprogramming to model-driven development, program analyses including
termination, inductive programming, program generation and applications of
machine learning and probabilistic search. PEPM focuses on techniques,
supporting theory, tools, and applications of the analysis and manipulation of
programs. Each technique or tool of program manipulation should have a clear,
although perhaps informal, statement of desired properties, along with an
argument how these properties could be achieved.

Topics of interest for PEPM'12 include, but are not limited to:

 - Program and model manipulation techniques such as:
   supercompilation, partial evaluation, fusion, on-the-fly program 
   adaptation, active libraries, program inversion, slicing, 
   symbolic execution, refactoring, decompilation, and obfuscation.

 - Program analysis techniques that are used to drive program/model
   manipulation such as: abstract interpretation, termination
   checking, binding-time analysis, constraint solving, type systems, 
   automated testing and test case generation.

 - Techniques that treat programs/models as data objects including
   metaprogramming, generative programming, embedded domain-specific
   languages, program synthesis by sketching and inductive programming, staged
   computation, and model-driven program generation and transformation.

 - Application of the above techniques including case studies of
   program manipulation in real-world (industrial, open-source)
   projects and software development processes,  descriptions of
   robust tools capable of effectively handling realistic applications,
   benchmarking. Examples of application domains include legacy
   program understanding and transformation, DSL implementations, 
   visual languages and end-user programming, scientific computing, 
   middleware frameworks and infrastructure needed for distributed and 
   web-based applications, resource-limited computation, and security.

To maintain the dynamic and interactive nature of PEPM, we will
continue the category of `short papers' for tool demonstrations and
for presentations of exciting if not fully polished research, and of
interesting academic, industrial and open-source applications that are
new or unfamiliar.

Student attendants with accepted papers can apply for a SIGPLAN PAC grant to
help cover travel expenses and other support.

All accepted papers, short papers included, will appear in formal proceedings
published by ACM Press. In addition to printed proceedings, accepted papers
will be included in the ACM Digital Library. Selected papers may later on be
invited for a journal special issue dedicated to PEPM'12.

The SIGPLAN Republication Policy and ACM's Policy and Procedures on Plagiarism
apply.

Submission Categories and Guidelines

Authors are strongly encouraged to consult the advice for authoring research
papers and tool papers before submitting. The PC Chairs welcome any inquiries
about the authoring advice.

Regular research papers must not exceed 10 pages in ACM Proceedings style.
Short papers are up to 4 pages in ACM Proceedings style. Authors of tool
demonstration proposals are expected to present a live demonstration of the
described tool at the workshop (tool papers should include an additional
appendix of up to 6 extra pages giving the outline, screenshots, examples, etc.
to indicate the content of the proposed live demo at the workshop).

Important Dates

 - Paper submission: Mon, October 10, 2011, 23:59, GMT
 - Author notification: Tue, November 8, 2011

 - Workshop: Mon-Tue, January 23-24, 2012

Invited Speakers
TBD


Program Chairs

 - Oleg Kiselyov (Monterey, CA, USA)
 - Simon Thompson (University of Kent, UK)

Program Committee Members

 - Emilie Balland (INRIA, France)
 - Ewen Denney (NASA Ames Research Center, USA)
 - Martin Erwig (Oregon State University, USA)
 - Sebastian Fischer (National Institute of Informatics, Japan)
 - Lidia Fuentes (Universidad de Malaga, Spain)
 - John Gallagher (Roskilde University, Denmark and IMDEA Software, Spain)
 - Dave Herman (Mozilla Labs)
 - Stefan Holdermans (Vector Fabrics, the Netherlands)
 - Christian Kaestner (University of Marburg, Germany)
 - Emanuel Kitzelmann (International Computer Science Institute, USA)
 - Andrei Klimov (Keldysh Institute of Applied Mathematics, Russian Academy of
Sciences)
 - Shin-Cheng Mu (Academia Sinica, Taiwan)
 - Alberto Pardo (Universidad de la Repu'blica, Uruguay)
 - Kostis Sagonas (Uppsala University, Sweden and National Technical
University of 

RE: Proposal: fix simple pattern binding and declaration group

2011-06-27 Thread Paterson, Ross
 For example, section 3.13 ends with the note:

   case x of { (a,_) | let b = not a in b :: Bool - a }

   ... Programmers are advised, therefore, to avoid guards that
   end with a type signature.

I would support changing a type signature to an expression type
signature in this note for consistency.

 There is no a priori reason why b should depend on a in a pair of
 bindings such as these:

a = const (\x - x) b
b = const (a :: Int - Int) (a :: Bool - Bool)

There is: section 3.16 says that in an expression type signature e::t,
the type derived for e must be more specific than t.  To derive the
type of e, in this case a, before matching it against t, we have no
alternative but to use the definition of a.

 Even if you don't think the report is ambiguous, it is at least prone
 to misinterpretation, which is why a couple of examples would really
 help at the end of 4.5.1.

Fair enough.  Perhaps the example on the H' page would help:

http://hackage.haskell.org/trac/haskell-prime/wiki/RelaxedDependencyAnalysis

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


Re: Proposal: fix simple pattern binding and declaration group

2011-06-27 Thread dm-list-haskell-prime
At Mon, 27 Jun 2011 15:02:33 +0100,
Paterson, Ross wrote:
 
  There is no a priori reason why b should depend on a in a pair of
  bindings such as these:
 
 a = const (\x - x) b
 b = const (a :: Int - Int) (a :: Bool - Bool)
 
 There is: section 3.16 says that in an expression type signature e::t,
 the type derived for e must be more specific than t.  To derive the
 type of e, in this case a, before matching it against t, we have no
 alternative but to use the definition of a.

I saw this, but I guess I didn't realize it was relevant to 4.5.1.
When I read 3.16, the following sentence:

the declared type may be more specific than the principal type
derivable from exp, but it is an error to give a type that is
more general than, or not comparable to, the principal type

seemed so obvious that I just glossed over it.  There's actually an
important point here, which is that in order to infer the type of an
expression type-signature e :: t, you first must infer the type of e,
and only then check it against t.  If this is the intent, it would be
clearer to say more specific than the principle type *derived* from
exp, rather than derivable, since the derivation must actually
happen.

But in fact, the relation of expression type signatures to type
inference is even subtler.  Expression type signatures *can* affect
type inference in code such as the following:

f1 () = 5 where { _ = f2; _ = n }
f2 () = f1 () :: Rational -- changes type of n to Rational
n = f1 ()

I guess the rule is that expression type signatures can affect type
inference by resolving ambiguities or avoiding defaulting, but not in
any other way?  To understand that, you have to understand sections
4.5.1 and 4.5.2, meaning we've come full circle.

And there's another sentence in 4.5.2 that makes this harder to
understand:

If the programmer supplies explicit type signatures for more
than one variable in a declaration group, the contexts of
these signatures must be identical up to renaming of the type
variables.

This makes it sound like declaration type signatures don't break up
declaration groups.  I suppose the above sentence is technically
applicable for non-simple pattern bindings, but it would be clearer to
add something along of the lines of ... type signatures for more than
one variable (which can occur when a non-simple pattern binding binds
multiple variables)

  Even if you don't think the report is ambiguous, it is at least prone
  to misinterpretation, which is why a couple of examples would really
  help at the end of 4.5.1.
 
 Fair enough.  Perhaps the example on the H' page would help:
 
 http://hackage.haskell.org/trac/haskell-prime/wiki/RelaxedDependencyAnalysis

Sure, that's a good example.  But it would also be nice to have an
example with an expression type signature, maybe with an explanation
that references 3.16 to make clear what is going on (and maybe with a
change of derivable - derived in 3.16).

David

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


Re: [Haskell-cafe] View Thunk Evaluation

2011-06-27 Thread Tom Murphy
That is so cool! Thank you.

To anyone who's interested: Try it. It's enlightening.

Tom

On 6/26/11, Don Stewart don...@gmail.com wrote:
 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


Re: [Haskell-cafe] Data.Time

2011-06-27 Thread Yitzchak Gale
Tony Morris wrote:
 I recently set out to write a library that required a decent time
 library. Having only had a flirt with Data.Time previously, I assumed
 it would be robust like many other haskell libraries. I don't know
 about consensus, but I have been massively let down. I won't go in to
 the details...

Data.Time is in some ways like Haskell itself. Though at first glance
it seems a little daunting, in reality its semantic correctness
makes it easier to use, not harder, than any of its alternatives
in any language that I know (and I am proficient in quite a few).
Once you have caught on, it is difficult to settle for anything less.

The biggest shortcoming, in my opinion, is that the documentation
assumes that the reader is very familiar with the Haskell type
system, and with viewing type signatures and instance lists as an
integral and central part of the documentation.

In particular, Haskell's standard numeric type classes and the
conversion functions between them play a central role in the API
of Data.Time. But you wouldn't realize that unless you have read
the type signatures and instance lists in the Haddocks very
carefully, and have thought about it for a while.

Another problem, as Malcolm pointed out, is that because of the
sheer size of the library, a quick-start guide for the common
cases would be extremely helpful for newcomers.

What other issues have you noticed?

 is there a reasonable alternative to Data.Time
 If I am right, and there is no alternative, I see no option but to
 take an excursion into writing my own.

No. There are several alternatives, but I have never seen anything
that has come close to Data.Time.

Before you undertake writing a whole new time library, why not
try writing some improved documentation for Data.Time first?
I think that would give the most immediate benefit to the
community, and I'm sure it would improve the quality of whatever
library of your own you end up writing.

Regards,
Yitz

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


Re: [Haskell-cafe] Period of a sequence

2011-06-27 Thread Steffen Schuldenzucker



On 06/26/2011 04:16 PM, michael rice wrote:

MathWorks has the function seqperiod(x) to return the period of sequence
x. Is there an equivalent function in Haskell?


Could you specify what exactly the function is supposed to do? I am 
pretty sure that a function like


seqPeriod :: (Eq a) = [a] - Maybe Integer  -- Nothing iff non-periodic

cannot be written. If sequences are represented by the terms that 
define them (or this information is at least accessible), chances might 
be better, but I would still be interested how such a function works. 
The problem seems undecidable to me in general.


On finite lists (which may be produced from infinite ones via 'take'), a 
naive implementation could be this:



 import Data.List (inits, cycle, isPrefixOf)
 import Debug.Trace

 -- Given a finite list, calculate its period.
 -- The first parameter controls what is accepted as a generator. See 
below.

 -- Set it to False when looking at chunks from an infinite sequence.
 listPeriod :: (Eq a) = Bool - [a] - Int
 listPeriod precisely xs = case filter (generates precisely xs) (inits 
xs) of

 -- as (last $ init xs) == xs, this will always suffice.
 (g:_) - length g  -- length of the *shortest* generator

 -- @generates prec xs g@ iff @g@ generates @xs@ by repitition. If 
@prec@, the

 -- lengths have to match, too. Consider
 --
 --  generates True [1,2,3,1,2,1,2] [1,2,3,1,2]
 -- False
 --
 --  generates False [1,2,3,1,2,1,2] [1,2,3,1,2]
 -- True
 generates :: (Eq a) = Bool - [a] - [a] - Bool
 generates precisely xs g = if null g
 then null xs
 else (not precisely || length xs `mod` length g == 0)
xs `isPrefixOf` cycle g


-- Steffen

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


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

2011-06-27 Thread John Lato

 From: David Place d...@vidplace.com

 Hi:

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


Iteratee's 'Data.Iteratee.Iteratee.convStream', or the more general
'Data.Iteratee.Iteratee.unfoldConvStream', would be the rough equivalents.
 The difference is that DEL.concatMap operates on each chunk, whereas
DII.convStream operates on the stream.  This makes it possible to specify
operations which work on multiple chunks.

If you want a function more like DEL.concatMap, it would be

 concatMap f = convStream (fmap f getChunk)

Note that stream type 's' in enumerator should generally be translated to
'[s]' in iteratee.

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


[Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread Steffen Schuldenzucker


Forwarding to -cafe

 Original Message 
Subject:Re: [Haskell-cafe] Period of a sequence
Date:   Mon, 27 Jun 2011 04:46:10 -0700 (PDT)
From:   michael rice nowg...@yahoo.com
To: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de



Hi Steffen,

Repeating decimals.

5/7 == 0.714285 714285 7142857 ... Period = 6

It does seem like a difficult problem.

This one is eventually repeating, with Period = 3

3227/555 = 5.8144 144 144…

Michael

--- On *Mon, 6/27/11, Steffen Schuldenzucker
/sschuldenzuc...@uni-bonn.de/*wrote:


From: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de
Subject: Re: [Haskell-cafe] Period of a sequence
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Monday, June 27, 2011, 4:32 AM



On 06/26/2011 04:16 PM, michael rice wrote:
  MathWorks has the function seqperiod(x) to return the period of
sequence
  x. Is there an equivalent function in Haskell?

Could you specify what exactly the function is supposed to do? I am
pretty sure that a function like

seqPeriod :: (Eq a) = [a] - Maybe Integer -- Nothing iff non-periodic

cannot be written. If sequences are represented by the terms that
define them (or this information is at least accessible), chances
might be better, but I would still be interested how such a function
works. The problem seems undecidable to me in general.

On finite lists (which may be produced from infinite ones via
'take'), a naive implementation could be this:

 
  import Data.List (inits, cycle, isPrefixOf)
  import Debug.Trace
 
  -- Given a finite list, calculate its period.
  -- The first parameter controls what is accepted as a generator.
See below.
  -- Set it to False when looking at chunks from an infinite sequence.
  listPeriod :: (Eq a) = Bool - [a] - Int
  listPeriod precisely xs = case filter (generates precisely xs)
(inits xs) of
  -- as (last $ init xs) == xs, this will always suffice.
  (g:_) - length g -- length of the *shortest* generator
 
  -- @generates prec xs g@ iff @g@ generates @xs@ by repitition. If
@prec@, the
  -- lengths have to match, too. Consider
  --
  --  generates True [1,2,3,1,2,1,2] [1,2,3,1,2]
  -- False
  --
  --  generates False [1,2,3,1,2,1,2] [1,2,3,1,2]
  -- True
  generates :: (Eq a) = Bool - [a] - [a] - Bool
  generates precisely xs g = if null g
  then null xs
  else (not precisely || length xs `mod` length g == 0)
   xs `isPrefixOf` cycle g
 

-- Steffen


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


Re: [Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread Steffen Schuldenzucker


Michael,

On 06/27/2011 01:51 PM, Steffen Schuldenzucker wrote:

 Forwarding to -cafe

  Original Message 
 Subject: Re: [Haskell-cafe] Period of a sequence
 Date: Mon, 27 Jun 2011 04:46:10 -0700 (PDT)
 From: michael rice nowg...@yahoo.com
 To: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de

 Hi Steffen,

 Repeating decimals.

 5/7 == 0.714285 714285 7142857 ... Period = 6

 It does seem like a difficult problem.

 This one is eventually repeating, with Period = 3

 3227/555 = 5.8144 144 144…

why not use the well-known division algorithm: (I hope this is readable)

3227 / 555
= 3227 `div` 555 + 3227 `mod` 555 / 555
= 5 + 452 / 555
= 5 + 0.1 * 4520 / 555
= 5 + 0.1 * (4520 `div` 555 + (4520 `mod` 555) / 555)
= 5 + 0.1 * (8 + 80 / 555)
= 5 + 0.1 * (8 + 0.1 * (800 / 555))
= 5 + 0.1 * (8 + 0.1 * (800 `div` 555 + (800 `mod` 555) / 555))
= 5 + 0.1 * (8 + 0.1 * (1 + 245 / 555))
= 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * 2450 / 555))
= 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 230 / 555)))
= 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 0.1 * 2300 / 555)))
= 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 0.1 * (4 + 80 / 555
*whoops*, saw 80 already, namely in line 6. Would go on like that 
forever if I continued like this, so the final result has to be:


vvv Part before the place where I saw the '80' first
5.8 144 144 144 ...
^^^ Part after I saw the '80'

So you could write a recursive function that takes as an accumulating 
parameter containing the list of numbers already seen:


-- periodOf n m gives the periodic part of n/m as a decimal fraction.
-- (or an empty list if that number has finitely many decimal places)
 periodOf :: (Integral a) = a - a - [a]
 periodOf = periodOfWorker []
   where
 periodOfWorker seen n m
 | n `mod` m == 0 = ...
 | (n `mod` m) `elem` seen = ...
 | otherwise = ...


--- On *Mon, 6/27/11, Steffen Schuldenzucker
/sschuldenzuc...@uni-bonn.de/*wrote:


From: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de
Subject: Re: [Haskell-cafe] Period of a sequence
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Monday, June 27, 2011, 4:32 AM



On 06/26/2011 04:16 PM, michael rice wrote:
  MathWorks has the function seqperiod(x) to return the period of
sequence
  x. Is there an equivalent function in Haskell?

Could you specify what exactly the function is supposed to do? I am
pretty sure that a function like

seqPeriod :: (Eq a) = [a] - Maybe Integer -- Nothing iff non-periodic

cannot be written. If sequences are represented by the terms that
define them (or this information is at least accessible), chances
might be better, but I would still be interested how such a function
works. The problem seems undecidable to me in general.

On finite lists (which may be produced from infinite ones via
'take'), a naive implementation could be this:

 
  import Data.List (inits, cycle, isPrefixOf)
  import Debug.Trace
 
  -- Given a finite list, calculate its period.
  -- The first parameter controls what is accepted as a generator.
See below.
  -- Set it to False when looking at chunks from an infinite sequence.
  listPeriod :: (Eq a) = Bool - [a] - Int
  listPeriod precisely xs = case filter (generates precisely xs)
(inits xs) of
  -- as (last $ init xs) == xs, this will always suffice.
  (g:_) - length g -- length of the *shortest* generator
 
  -- @generates prec xs g@ iff @g@ generates @xs@ by repitition. If
@prec@, the
  -- lengths have to match, too. Consider
  --
  --  generates True [1,2,3,1,2,1,2] [1,2,3,1,2]
  -- False
  --
  --  generates False [1,2,3,1,2,1,2] [1,2,3,1,2]
  -- True
  generates :: (Eq a) = Bool - [a] - [a] - Bool
  generates precisely xs g = if null g
  then null xs
  else (not precisely || length xs `mod` length g == 0)
   xs `isPrefixOf` cycle g
 

-- Steffen


___
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] Data.Time

2011-06-27 Thread Daniel Schüssler
On 2011-June-27 Monday 10:15:28 Yitzchak Gale wrote:
 The biggest shortcoming, in my opinion, is that the documentation
 assumes that the reader is very familiar with the Haskell type
 system, and with viewing type signatures and instance lists as an
 integral and central part of the documentation.
 
 In particular, Haskell's standard numeric type classes and the
 conversion functions between them play a central role in the API
 of Data.Time.

Making use of Haddock's recently added(?) support for comments on instance 
declaration would help a lot here, I think (even if it was just to draw 
attention to the Num/Integral/Real/Fractional instances).

  Before you undertake writing a whole new time library, why not
 try writing some improved documentation for Data.Time first?

I got the impression that Tony's issue with Data.Time was the lack of some 
feature, not usability. Seems like the details that were omitted for the sake 
of constructiveness are quite relevant :)

Cheers,
Daniel

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


Re: [Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread Brent Yorgey
I've attached some code I wrote a while ago for playing with repeating
decimal expansions, perhaps you'll find some of it useful.

-Brent

On Mon, Jun 27, 2011 at 02:21:55PM +0200, Steffen Schuldenzucker wrote:
 
 Michael,
 
 On 06/27/2011 01:51 PM, Steffen Schuldenzucker wrote:
 
  Forwarding to -cafe
 
   Original Message 
  Subject: Re: [Haskell-cafe] Period of a sequence
  Date: Mon, 27 Jun 2011 04:46:10 -0700 (PDT)
  From: michael rice nowg...@yahoo.com
  To: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de
 
  Hi Steffen,
 
  Repeating decimals.
 
  5/7 == 0.714285 714285 7142857 ... Period = 6
 
  It does seem like a difficult problem.
 
  This one is eventually repeating, with Period = 3
 
  3227/555 = 5.8144 144 144…
 
 why not use the well-known division algorithm: (I hope this is readable)
 
 3227 / 555
 = 3227 `div` 555 + 3227 `mod` 555 / 555
 = 5 + 452 / 555
 = 5 + 0.1 * 4520 / 555
 = 5 + 0.1 * (4520 `div` 555 + (4520 `mod` 555) / 555)
 = 5 + 0.1 * (8 + 80 / 555)
 = 5 + 0.1 * (8 + 0.1 * (800 / 555))
 = 5 + 0.1 * (8 + 0.1 * (800 `div` 555 + (800 `mod` 555) / 555))
 = 5 + 0.1 * (8 + 0.1 * (1 + 245 / 555))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * 2450 / 555))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 230 / 555)))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 0.1 * 2300 / 555)))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 0.1 * (4 + 80 / 555
 *whoops*, saw 80 already, namely in line 6. Would go on like that
 forever if I continued like this, so the final result has to be:
 
 vvv Part before the place where I saw the '80' first
 5.8 144 144 144 ...
 ^^^ Part after I saw the '80'
 
 So you could write a recursive function that takes as an accumulating
 parameter containing the list of numbers already seen:
 
 -- periodOf n m gives the periodic part of n/m as a decimal fraction.
 -- (or an empty list if that number has finitely many decimal places)
  periodOf :: (Integral a) = a - a - [a]
  periodOf = periodOfWorker []
where
  periodOfWorker seen n m
  | n `mod` m == 0 = ...
  | (n `mod` m) `elem` seen = ...
  | otherwise = ...
 
 --- On *Mon, 6/27/11, Steffen Schuldenzucker
 /sschuldenzuc...@uni-bonn.de/*wrote:
 
 
 From: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de
 Subject: Re: [Haskell-cafe] Period of a sequence
 To: michael rice nowg...@yahoo.com
 Cc: haskell-cafe@haskell.org
 Date: Monday, June 27, 2011, 4:32 AM
 
 
 
 On 06/26/2011 04:16 PM, michael rice wrote:
   MathWorks has the function seqperiod(x) to return the period of
 sequence
   x. Is there an equivalent function in Haskell?
 
 Could you specify what exactly the function is supposed to do? I am
 pretty sure that a function like
 
 seqPeriod :: (Eq a) = [a] - Maybe Integer -- Nothing iff non-periodic
 
 cannot be written. If sequences are represented by the terms that
 define them (or this information is at least accessible), chances
 might be better, but I would still be interested how such a function
 works. The problem seems undecidable to me in general.
 
 On finite lists (which may be produced from infinite ones via
 'take'), a naive implementation could be this:
 
  
   import Data.List (inits, cycle, isPrefixOf)
   import Debug.Trace
  
   -- Given a finite list, calculate its period.
   -- The first parameter controls what is accepted as a generator.
 See below.
   -- Set it to False when looking at chunks from an infinite sequence.
   listPeriod :: (Eq a) = Bool - [a] - Int
   listPeriod precisely xs = case filter (generates precisely xs)
 (inits xs) of
   -- as (last $ init xs) == xs, this will always suffice.
   (g:_) - length g -- length of the *shortest* generator
  
   -- @generates prec xs g@ iff @g@ generates @xs@ by repitition. If
 @prec@, the
   -- lengths have to match, too. Consider
   --
   --  generates True [1,2,3,1,2,1,2] [1,2,3,1,2]
   -- False
   --
   --  generates False [1,2,3,1,2,1,2] [1,2,3,1,2]
   -- True
   generates :: (Eq a) = Bool - [a] - [a] - Bool
   generates precisely xs g = if null g
   then null xs
   else (not precisely || length xs `mod` length g == 0)
xs `isPrefixOf` cycle g
  
 
 -- Steffen
 
 
 ___
 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
import qualified Data.Map as M
import Data.Maybe
import Data.Ratio
import Data.List
import Data.Char
import Control.Arrow

import Test.QuickCheck

f n (d,r) = ((10*r) `divMod` n)

-- Given a list and a way to extract a tag for each element, find the
-- indices of the list giving the first and second occurrence of the
-- first element to repeat, or Nothing if there are no repeats.
findRep :: Ord b = (a - b) - [a] - Maybe (Int,Int)
findRep = findRep' M.empty 0

findRep' :: Ord b = M.Map b Int - Int - (a - b) - [a] - Maybe (Int,Int)
findRep' _ 

Re: [Haskell-cafe] Data.Time

2011-06-27 Thread briand
On Mon, 27 Jun 2011 11:15:28 +0300
Yitzchak Gale g...@sefer.org wrote:

 
 The biggest shortcoming, in my opinion, is that the documentation
 assumes that the reader is very familiar with the Haskell type
 system, and with viewing type signatures and instance lists as an
 integral and central part of the documentation.
 
 In particular, Haskell's standard numeric type classes and the
 conversion functions between them play a central role in the API
 of Data.Time. But you wouldn't realize that unless you have read
 the type signatures and instance lists in the Haddocks very
 carefully, and have thought about it for a while.

This is exactly right.

 
 Another problem, as Malcolm pointed out, is that because of the
 sheer size of the library, a quick-start guide for the common
 cases would be extremely helpful for newcomers.

That would be very, very helpful.  I had a few working examples things were 
much better.  Finding a starting place, any starting place, proved to be quite 
elusive.  Also the fact that asking for the current time traps you in IO hell, 
doesn't help, although it's clear that it should be that way.

Brian

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


Re: [Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread michael rice
Thanks, all.
I have an evaluation copy of Mathematica and have been looking for problems to 
feed it.
Michael
--- On Mon, 6/27/11, Brent Yorgey byor...@seas.upenn.edu wrote:

From: Brent Yorgey byor...@seas.upenn.edu
Subject: Re: [Haskell-cafe] Fwd: Re:  Period of a sequence
To: haskell-cafe@haskell.org
Date: Monday, June 27, 2011, 9:56 AM

I've attached some code I wrote a while ago for playing with repeating
decimal expansions, perhaps you'll find some of it useful.

-Brent

On Mon, Jun 27, 2011 at 02:21:55PM +0200, Steffen Schuldenzucker wrote:
 
 Michael,
 
 On 06/27/2011 01:51 PM, Steffen Schuldenzucker wrote:
 
  Forwarding to -cafe
 
   Original Message 
  Subject: Re: [Haskell-cafe] Period of a sequence
  Date: Mon, 27 Jun 2011 04:46:10 -0700 (PDT)
  From: michael rice nowg...@yahoo.com
  To: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de
 
  Hi Steffen,
 
  Repeating decimals.
 
  5/7 == 0.714285 714285 7142857 ... Period = 6
 
  It does seem like a difficult problem.
 
  This one is eventually repeating, with Period = 3
 
  3227/555 = 5.8144 144 144…
 
 why not use the well-known division algorithm: (I hope this is readable)
 
 3227 / 555
 = 3227 `div` 555 + 3227 `mod` 555 / 555
 = 5 + 452 / 555
 = 5 + 0.1 * 4520 / 555
 = 5 + 0.1 * (4520 `div` 555 + (4520 `mod` 555) / 555)
 = 5 + 0.1 * (8 + 80 / 555)
 = 5 + 0.1 * (8 + 0.1 * (800 / 555))
 = 5 + 0.1 * (8 + 0.1 * (800 `div` 555 + (800 `mod` 555) / 555))
 = 5 + 0.1 * (8 + 0.1 * (1 + 245 / 555))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * 2450 / 555))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 230 / 555)))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 0.1 * 2300 / 555)))
 = 5 + 0.1 * (8 + 0.1 * (1 + 0.1 * (4 + 0.1 * (4 + 80 / 555
 *whoops*, saw 80 already, namely in line 6. Would go on like that
 forever if I continued like this, so the final result has to be:
 
 vvv Part before the place where I saw the '80' first
 5.8 144 144 144 ...
     ^^^ Part after I saw the '80'
 
 So you could write a recursive function that takes as an accumulating
 parameter containing the list of numbers already seen:
 
 -- periodOf n m gives the periodic part of n/m as a decimal fraction.
 -- (or an empty list if that number has finitely many decimal places)
  periodOf :: (Integral a) = a - a - [a]
  periodOf = periodOfWorker []
    where
      periodOfWorker seen n m
          | n `mod` m == 0 = ...
          | (n `mod` m) `elem` seen = ...
          | otherwise = ...
 
 --- On *Mon, 6/27/11, Steffen Schuldenzucker
 /sschuldenzuc...@uni-bonn.de/*wrote:
 
 
 From: Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de
 Subject: Re: [Haskell-cafe] Period of a sequence
 To: michael rice nowg...@yahoo.com
 Cc: haskell-cafe@haskell.org
 Date: Monday, June 27, 2011, 4:32 AM
 
 
 
 On 06/26/2011 04:16 PM, michael rice wrote:
   MathWorks has the function seqperiod(x) to return the period of
 sequence
   x. Is there an equivalent function in Haskell?
 
 Could you specify what exactly the function is supposed to do? I am
 pretty sure that a function like
 
 seqPeriod :: (Eq a) = [a] - Maybe Integer -- Nothing iff non-periodic
 
 cannot be written. If sequences are represented by the terms that
 define them (or this information is at least accessible), chances
 might be better, but I would still be interested how such a function
 works. The problem seems undecidable to me in general.
 
 On finite lists (which may be produced from infinite ones via
 'take'), a naive implementation could be this:
 
  
   import Data.List (inits, cycle, isPrefixOf)
   import Debug.Trace
  
   -- Given a finite list, calculate its period.
   -- The first parameter controls what is accepted as a generator.
 See below.
   -- Set it to False when looking at chunks from an infinite sequence.
   listPeriod :: (Eq a) = Bool - [a] - Int
   listPeriod precisely xs = case filter (generates precisely xs)
 (inits xs) of
   -- as (last $ init xs) == xs, this will always suffice.
   (g:_) - length g -- length of the *shortest* generator
  
   -- @generates prec xs g@ iff @g@ generates @xs@ by repitition. If
 @prec@, the
   -- lengths have to match, too. Consider
   --
   --  generates True [1,2,3,1,2,1,2] [1,2,3,1,2]
   -- False
   --
   --  generates False [1,2,3,1,2,1,2] [1,2,3,1,2]
   -- True
   generates :: (Eq a) = Bool - [a] - [a] - Bool
   generates precisely xs g = if null g
   then null xs
   else (not precisely || length xs `mod` length g == 0)
xs `isPrefixOf` cycle g
  
 
 -- Steffen
 
 
 ___
 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

-Inline Attachment Follows-

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

Re: [Haskell-cafe] Help

2011-06-27 Thread Stoyan Peev
Yes, how can i miss that...

It's working now, but still it works only for the first element of the
list. It prints the result only for the first string. Now when it's
operational, i have just to modify it to be working for all of the
elements of the list.
If i run the program right now, the results are:

Main p [2*3,4/2]
6


I'm not so sure, if i have to modify the caller function only, or i
have to modify both the caller function and the exact function that
makes the parsing?

2011/6/25 Jack Henahan jhena...@uvm.edu:
 The error in ghci is

 Couldn't match expected type `Int' with actual type `[a0]'
    In the expression: []
    In an equation for `p': p [] = []

 You've defined p as [String] - Int, but then your base case is p [] = []. [] 
 is not an Int. I changed it to 0 and it'll compile, at least, but I'm not 
 sure if that's the effect you're after.

 http://hpaste.org/48324
 Edited code (really just indentation changes and the change from p [] = [] to 
 p [] = 0)

 On Jun 25, 2011, at 3:19 PM, Stoyan Peev wrote:

 First I am using WinHugs.

 that's the code i made so far but it's still not working:

 http://hpaste.org/48318


 Error:
 ERROR file:.\kursovazadacha.hs:36 - Type error in explicitly typed binding
 *** Term           : p
 *** Type           : [String] - [a]
 *** Does not match : [String] - Int


 I'm still breaking down somewhere ...



 2011/6/25 Daniel Patterson lists.hask...@dbp.mm.st:
 what haskell compiler are you using? And what does the include line do?

 That does not look like a GHC error message (the only compiler I'm familiar 
 with), but it seems like it is saying that you should not have the extra 
 newlines between the function type signature and declaration. - that's only 
 my guess, based on the assumption that the whitespace is being converted to 
 a syntax with explicit semilcolon line terminations.

 now, looking at the actual code, the type of the parse function is [a] - 
 [a]. This means that you can parse a list of anything into a list of 
 anything, which doesnt make much sense. This should probably be [String] - 
 [String]  (you are parsing a list of strings to a list of strings, yes?). 
 Now the base case of parse (the first case) makes sense, but look at the 
 second case. parse is being given a list of elements (which you have used 
 pattern matching to decompose, but the whole argument, (x:xs), is a list of 
 elements). You are then passing that, unchanged, to eval. This means that 
 eval must take the same type. Does it? how would you apply eval to each 
 element in that list, instead of just applying it to the whole list?

 On Jun 24, 2011, at 4:31 PM, Stoyan Peev wrote:

 I found the library myself, and i already put the code in that site:

 http://hpaste.org/48277



 That's what i have tried to do for making the task by calling the one
 string function by another one:

 include kursovazadacha

 parse :: [a] - [a]

 parse [] = []

 parse (x:xs) = eval (x:xs)


 The error from the compiler:

 ERROR file:.\list.hs:3 - Syntax error in declaration (unexpected `;',
 possibly due to bad layout)


 On Fri, Jun 24, 2011 at 11:20 PM, Daniel Patterson
 lists.hask...@dbp.mm.st wrote:
 What have you tried to do in order to make it work for the list, and what 
 error results? What is confusing about the error message? More generally, 
 how could you transform an operation on a single string into one that 
 does the same thing to a list of strings? You've probably talked about 
 higher order functions in your class - would any of the common ones 
 (filter, map, foldr) be helpful here? Would any encapsulate what you are 
 trying to do?

  If you include these kinds of things, I think you'll find this community 
 to be very helpful; without that (showing what your thought process is, 
 why it isn't working, what seems confusing about what the haskell 
 compiler is telling you, etc), you are not going to get help here. People 
 here are very friendly and willing to help people learn; this is not a 
 place to come to get an assignment finished :)

 Also, could you put the library you are using (I'm assuming that this is 
 provided by your university) and the code on somewhere like hpaste.org, 
 so that the formatting is not messed up by email, and it is syntax 
 highlighted?

 On Jun 24, 2011, at 3:57 PM, Stoyan Peev wrote:

 Hello all,

 I am experiencing some issues to do my course task in university.

 I have to write a calculator- function in Haskell. The function
 argument is a list of strings and also form such list, as each string
 of the argument made definite action:
 - If the string has the form of an arithmetic _expression_ - calculate
 this _expression_. The string result becomes part of the list-result.
 If the _expression_ contains a variable which is not assigned value,
 the result is displayed undefined.
 - If the string has the form- Name = value calculated from the last
 _expression_ is assigned to the variable with the corresponding name
 in the list, 

Re: [Haskell-cafe] Help

2011-06-27 Thread Daniel Patterson
so think about the high level design for a second, and let that guide the 
types. then the types should guide the code.

p, which I assume is the top level evaluation, is supposed to take a list of 
strings, and produce a list of integers (the result of evaluating the 
expression), right? So it should have type p :: [String] - [Int].

Now the base case is obvious - if you are given an empty list of strings, then 
you should give back an empty list of results. 

The recursive case is a little more complicated - the idea with simple 
recursion is that the recursive case should eventually land you at the base 
case, which will stop the recursion. With lists, this usually means that each 
application of the recursive case should call itself on the rest of the list, 
and somehow process the first element of the list (it doesnt have to be this 
way, but often is).

So in your case, the recursive case should be: evaluate the first element of 
the list, and then call the whole function on the rest of the list. You can 
check this mentally by using a couple examples. In the case of a one element 
list, this means that it will evaluate the first (and only) element of the 
list, and then call itself on the rest of the list, which is an empty list, 
which is the bottom case and therefore ends the recursion. On a two element 
list, this can be checked as well. 

Now the types should be your best friend. You know that you want:

p :: [String] - [Int] 

That is from the problem statement. 

So you write the base case first:

p [] = []

Now for the recursive case, you know you want to eval the first element, and 
then call the function on the rest of the list. But since you need to return a 
list eventually, then you need to return a list in this function. You know that 
calling the function recursively will result in a list (the type guarantees 
that), so if you've evaluated the first element of a list, resulting in an Int, 
and you have a list of Int's that is the rest of the list, how do you combine 
those? Well, put the element at the beginning of the list!

p (x:xs) = (eval p) : (p xs)


Now this is a really really common pattern - do the same thing to every element 
of a list. The first thing in haskell to do if you think that what you are 
doing might already exist in some generalized form is to try to describe what 
the function is that you want. So in our case, you want a function that takes 
another function and applies it to every element in the list. This function 
would have type:

(a - b) - [a] - [b]

In your case the (a - b) is String - Int (the function eval), the [a] is 
[String], [b] is [Int]. Now if you take this and search on Hoogle (a haskell 
search engine: 
http://haskell.org/hoogle/?hoogle=%28a+-%3E+b%29+-%3E+%5Ba%5D+-%3E+%5Bb%5D ), 
the first result is a function called map, which does exactly what you want. So 
you can actually write your whole p function as:

p :: [String] - [Int]
p xs = map eval xs

Or, if you are okay with partial application, this is equivalent to:
p :: [String] - [Int]
p = map eval

On Jun 25, 2011, at 3:56 PM, Jack Henahan wrote:

 The error in ghci is
 
 Couldn't match expected type `Int' with actual type `[a0]'
In the expression: []
In an equation for `p': p [] = []
 
 You've defined p as [String] - Int, but then your base case is p [] = []. [] 
 is not an Int. I changed it to 0 and it'll compile, at least, but I'm not 
 sure if that's the effect you're after.
 
 http://hpaste.org/48324
 Edited code (really just indentation changes and the change from p [] = [] to 
 p [] = 0)
 
 On Jun 25, 2011, at 3:19 PM, Stoyan Peev wrote:
 
 First I am using WinHugs.
 
 that's the code i made so far but it's still not working:
 
 http://hpaste.org/48318
 
 
 Error:
 ERROR file:.\kursovazadacha.hs:36 - Type error in explicitly typed binding
 *** Term   : p
 *** Type   : [String] - [a]
 *** Does not match : [String] - Int
 
 
 I'm still breaking down somewhere ...
 
 
 
 2011/6/25 Daniel Patterson lists.hask...@dbp.mm.st:
 what haskell compiler are you using? And what does the include line do?
 
 That does not look like a GHC error message (the only compiler I'm familiar 
 with), but it seems like it is saying that you should not have the extra 
 newlines between the function type signature and declaration. - that's only 
 my guess, based on the assumption that the whitespace is being converted to 
 a syntax with explicit semilcolon line terminations.
 
 now, looking at the actual code, the type of the parse function is [a] - 
 [a]. This means that you can parse a list of anything into a list of 
 anything, which doesnt make much sense. This should probably be [String] - 
 [String]  (you are parsing a list of strings to a list of strings, yes?). 
 Now the base case of parse (the first case) makes sense, but look at the 
 second case. parse is being given a list of elements (which you have used 
 pattern matching to decompose, but the whole argument, (x:xs), is a 

Re: [Haskell-cafe] Help

2011-06-27 Thread Stoyan Peev
Yeah, that really helped me :))

Finally i got the results i wanted :

Main p [2*34/3,2+3,2*(6/2)]
[22,5,6]


There is only one more question i have about this.  I have already
written 2 error captures, but they don't really apply to the task i
have. Here are my error captures:

[(_,out)] - error (неопределено)
[]- 0

and here is the result

Parsing p [2*34/3,2+3,2*(6 / 2),]
[22,5,6,0]

It's ok for me, but i have to make it, not showing anything if there are blanks.
I suggest i had to make some checking in the caller function before
calling the eval funcition.
Also somehow i have to check the syntax of the string and if it is
like =x, the result should be x= previous string

Probably i have to user where for the caller function or some if cases :?




2011/6/27 Daniel Patterson lists.hask...@dbp.mm.st:
 so think about the high level design for a second, and let that guide the 
 types. then the types should guide the code.

 p, which I assume is the top level evaluation, is supposed to take a list of 
 strings, and produce a list of integers (the result of evaluating the 
 expression), right? So it should have type p :: [String] - [Int].

 Now the base case is obvious - if you are given an empty list of strings, 
 then you should give back an empty list of results.

 The recursive case is a little more complicated - the idea with simple 
 recursion is that the recursive case should eventually land you at the base 
 case, which will stop the recursion. With lists, this usually means that each 
 application of the recursive case should call itself on the rest of the list, 
 and somehow process the first element of the list (it doesnt have to be this 
 way, but often is).

 So in your case, the recursive case should be: evaluate the first element of 
 the list, and then call the whole function on the rest of the list. You can 
 check this mentally by using a couple examples. In the case of a one element 
 list, this means that it will evaluate the first (and only) element of the 
 list, and then call itself on the rest of the list, which is an empty list, 
 which is the bottom case and therefore ends the recursion. On a two element 
 list, this can be checked as well.

 Now the types should be your best friend. You know that you want:

 p :: [String] - [Int]

 That is from the problem statement.

 So you write the base case first:

 p [] = []

 Now for the recursive case, you know you want to eval the first element, and 
 then call the function on the rest of the list. But since you need to return 
 a list eventually, then you need to return a list in this function. You know 
 that calling the function recursively will result in a list (the type 
 guarantees that), so if you've evaluated the first element of a list, 
 resulting in an Int, and you have a list of Int's that is the rest of the 
 list, how do you combine those? Well, put the element at the beginning of the 
 list!

 p (x:xs) = (eval p) : (p xs)


 Now this is a really really common pattern - do the same thing to every 
 element of a list. The first thing in haskell to do if you think that what 
 you are doing might already exist in some generalized form is to try to 
 describe what the function is that you want. So in our case, you want a 
 function that takes another function and applies it to every element in the 
 list. This function would have type:

 (a - b) - [a] - [b]

 In your case the (a - b) is String - Int (the function eval), the [a] is 
 [String], [b] is [Int]. Now if you take this and search on Hoogle (a haskell 
 search engine: 
 http://haskell.org/hoogle/?hoogle=%28a+-%3E+b%29+-%3E+%5Ba%5D+-%3E+%5Bb%5D ), 
 the first result is a function called map, which does exactly what you want. 
 So you can actually write your whole p function as:

 p :: [String] - [Int]
 p xs = map eval xs

 Or, if you are okay with partial application, this is equivalent to:
 p :: [String] - [Int]
 p = map eval

 On Jun 25, 2011, at 3:56 PM, Jack Henahan wrote:

 The error in ghci is

 Couldn't match expected type `Int' with actual type `[a0]'
    In the expression: []
    In an equation for `p': p [] = []

 You've defined p as [String] - Int, but then your base case is p [] = []. 
 [] is not an Int. I changed it to 0 and it'll compile, at least, but I'm not 
 sure if that's the effect you're after.

 http://hpaste.org/48324
 Edited code (really just indentation changes and the change from p [] = [] 
 to p [] = 0)

 On Jun 25, 2011, at 3:19 PM, Stoyan Peev wrote:

 First I am using WinHugs.

 that's the code i made so far but it's still not working:

 http://hpaste.org/48318


 Error:
 ERROR file:.\kursovazadacha.hs:36 - Type error in explicitly typed binding
 *** Term           : p
 *** Type           : [String] - [a]
 *** Does not match : [String] - Int


 I'm still breaking down somewhere ...



 2011/6/25 Daniel Patterson lists.hask...@dbp.mm.st:
 what haskell compiler are 

[Haskell-cafe] Fwd: Data.Time

2011-06-27 Thread Daniel Patterson
sent from wrong account - message follows:

 I've found most of the time library to be quite useful, but the parsing to be 
 worthless (I've tried to get someone to prove me wrong already, and would be 
 happy if someone could on this thread!). 
 
 Specifically, the formatTime function, if it ever strips out padding (by 
 zeros or spaces), results in a time that is unparseable. The fact that 
 formatTime and parseTime are not capable of being inverses of each other 
 seems like a major flaw, when you think that this is not a parseable date:
 
 2011/1/30 (because the month must be padded by zeros).
 
 Even though it is very easy to print, and occurs commonly in the world.
 
 Because of this, I use formatTime to write my times, and then have a custom 
 parser to parse them back out. Which makes me think that this is a broken 
 library
 
 On Jun 27, 2011, at 10:37 AM, bri...@aracnet.com bri...@aracnet.com wrote:
 
 On Mon, 27 Jun 2011 11:15:28 +0300
 Yitzchak Gale g...@sefer.org wrote:
 
 
 The biggest shortcoming, in my opinion, is that the documentation
 assumes that the reader is very familiar with the Haskell type
 system, and with viewing type signatures and instance lists as an
 integral and central part of the documentation.
 
 In particular, Haskell's standard numeric type classes and the
 conversion functions between them play a central role in the API
 of Data.Time. But you wouldn't realize that unless you have read
 the type signatures and instance lists in the Haddocks very
 carefully, and have thought about it for a while.
 
 This is exactly right.
 
 
 Another problem, as Malcolm pointed out, is that because of the
 sheer size of the library, a quick-start guide for the common
 cases would be extremely helpful for newcomers.
 
 That would be very, very helpful.  I had a few working examples things were 
 much better.  Finding a starting place, any starting place, proved to be 
 quite elusive.  Also the fact that asking for the current time traps you in 
 IO hell, doesn't help, although it's clear that it should be that way.
 
 Brian
 
 ___
 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] Help

2011-06-27 Thread Daniel Patterson
Well, if you are at all familiar with (or wanted to learn about) the Maybe 
type, I would suggest you use that. A brief synopsis:

data Maybe a = Nothing | Just a

Which means that a Maybe Int is either Nothing or or Just an int. 

If you were to got this path, then your p function should have type [String] - 
[Maybe Int] - which means that either the calculator has a response (Just 22 or 
Just 6 or Just whatever) or something went wrong (invalid input) and it gave 
Nothing. 

So in your case, you'd get:
 Parsing p [2*34/3,2+3,2*(6 / 2),]
 [Just 22,Just 5,Just 6,Nothing]


Which really clearly demonstrates what you are trying to communicate (and 
importantly doesn't cause the whole program to stop running when it sees a bad 
input). 

Then in the eval function, the error cases would result in Nothing, and the 
good cases would result in Just n. 

On Jun 27, 2011, at 12:09 PM, Stoyan Peev wrote:

 Yeah, that really helped me :))
 
 Finally i got the results i wanted :
 
 Main p [2*34/3,2+3,2*(6/2)]
 [22,5,6]
 
 
 There is only one more question i have about this.  I have already
 written 2 error captures, but they don't really apply to the task i
 have. Here are my error captures:
 
[(_,out)] - error (неопределено)
[]- 0
 
 and here is the result
 
 Parsing p [2*34/3,2+3,2*(6 / 2),]
 [22,5,6,0]
 
 It's ok for me, but i have to make it, not showing anything if there are 
 blanks.
 I suggest i had to make some checking in the caller function before
 calling the eval funcition.
 Also somehow i have to check the syntax of the string and if it is
 like =x, the result should be x= previous string
 
 Probably i have to user where for the caller function or some if cases :?
 
 
 
 
 2011/6/27 Daniel Patterson lists.hask...@dbp.mm.st:
 so think about the high level design for a second, and let that guide the 
 types. then the types should guide the code.
 
 p, which I assume is the top level evaluation, is supposed to take a list of 
 strings, and produce a list of integers (the result of evaluating the 
 expression), right? So it should have type p :: [String] - [Int].
 
 Now the base case is obvious - if you are given an empty list of strings, 
 then you should give back an empty list of results.
 
 The recursive case is a little more complicated - the idea with simple 
 recursion is that the recursive case should eventually land you at the base 
 case, which will stop the recursion. With lists, this usually means that 
 each application of the recursive case should call itself on the rest of the 
 list, and somehow process the first element of the list (it doesnt have to 
 be this way, but often is).
 
 So in your case, the recursive case should be: evaluate the first element of 
 the list, and then call the whole function on the rest of the list. You can 
 check this mentally by using a couple examples. In the case of a one element 
 list, this means that it will evaluate the first (and only) element of the 
 list, and then call itself on the rest of the list, which is an empty list, 
 which is the bottom case and therefore ends the recursion. On a two element 
 list, this can be checked as well.
 
 Now the types should be your best friend. You know that you want:
 
 p :: [String] - [Int]
 
 That is from the problem statement.
 
 So you write the base case first:
 
 p [] = []
 
 Now for the recursive case, you know you want to eval the first element, and 
 then call the function on the rest of the list. But since you need to return 
 a list eventually, then you need to return a list in this function. You know 
 that calling the function recursively will result in a list (the type 
 guarantees that), so if you've evaluated the first element of a list, 
 resulting in an Int, and you have a list of Int's that is the rest of the 
 list, how do you combine those? Well, put the element at the beginning of 
 the list!
 
 p (x:xs) = (eval p) : (p xs)
 
 
 Now this is a really really common pattern - do the same thing to every 
 element of a list. The first thing in haskell to do if you think that what 
 you are doing might already exist in some generalized form is to try to 
 describe what the function is that you want. So in our case, you want a 
 function that takes another function and applies it to every element in the 
 list. This function would have type:
 
 (a - b) - [a] - [b]
 
 In your case the (a - b) is String - Int (the function eval), the [a] is 
 [String], [b] is [Int]. Now if you take this and search on Hoogle (a haskell 
 search engine: 
 http://haskell.org/hoogle/?hoogle=%28a+-%3E+b%29+-%3E+%5Ba%5D+-%3E+%5Bb%5D 
 ), the first result is a function called map, which does exactly what you 
 want. So you can actually write your whole p function as:
 
 p :: [String] - [Int]
 p xs = map eval xs
 
 Or, if you are okay with partial application, this is equivalent to:
 p :: [String] - [Int]
 p = map eval
 
 On Jun 25, 2011, at 3:56 

[Haskell-cafe] Installation Failed: Haskell Platform 2011.2.0.1-i386 for OS X

2011-06-27 Thread John Velman
I'm running OS X 10.6.7, XCode 3.2.5.  When  I try to install The Haskell
Platform 2011.2.0.1 for Mac OS X 10.6 (Snow Leopard)  it goes all the way
through to running package scripts, then says installation failed

I did two separate downloads, and tried the first installation two time,
the second download one time.  Same result all three times.

Is this a problem with the package, or ?  Any suggestions?

Thanks,

John Velman

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


Re: [Haskell-cafe] toSql and fromSql, for Algebraic Data Type

2011-06-27 Thread Ertugrul Soeylemez
Tom Murphy amin...@gmail.com wrote:

  The title is self-explanatory. I'd like to store information from
 an algebraic data type in an SQL database, but the type signature of
 toSql (toSql
   :: Data.Convertible.Base.Convertible a SqlValue = a - SqlValue)
 doesn't make sense to me.
  How is this done (how do I make an instance of a typeclass like that?)

My answer is:  This is tiring, redundant work.  Honestly, don't do it,
if you can avoid it.  Rather find a type with a ready-made Convertible
instance, which can represent the values of your type and convert to and
from that one instead.

By the way, if your type is just an enumeration of nullary constructors,
note that most database systems support efficient 'ENUM' types.  For
example in PostgreSQL you can do this:

CREATE TYPE server_status AS ENUM(
'online',
'offline',
'not available');

According to the documentation columns of type server_status will use
a compact, efficient 32 bit integer representation, but on the interface
you can work with regular strings, so you can just convert your
algebraic type to and from strings.

Even better, if you don't mind being tied to the particular database
system, you can abstract away such types by using stored procedures.


Greets,
Ertugrul


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



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


Re: [Haskell-cafe] Hoopl: Combining CheckingFuelMonad with State?

2011-06-27 Thread Justin Bailey
I asked this question on StackOverflow and someone suggested using
StateT. Unfortunately I don't think I can really carry around the
state I'd like to:

  
http://stackoverflow.com/questions/6495320/hoopl-how-can-i-combine-the-checkingfuelmonad-with-a-state-monad



On Fri, Jun 24, 2011 at 5:56 PM, Antoine Latter aslat...@gmail.com wrote:
 Hi Justin, this message might be better on the haskell-cafe list (or
 the excellent beginers list!).

 When you tried to write the get/put implementations, what problems
 were you running into?

 Antoine

 On Sat, Jun 25, 2011 at 7:50 AM, Justin Bailey jgbai...@gmail.com wrote:
 I'd like to carry around some state when rewriting. It seems like
 CheckingFuelMonad, etc. are set up to use with other monads but I
 can't get the types to agree.

 Using MTL I've managed to come up with these types:

 newtype RewriteOnce a = R (State Bool a)
   deriving (Monad)

 instance MonadState s (CheckingFuelMonad RewriteOnce) where
   get = undefined
   put = undefined


 But I cannot write the definitions for get and put. Is this possible
 or am I misundersanding CheckingFuelMonad? Is there a better approach
 altogether?

 Thanks in advance for any help!

 Justin

 ___
 Glasgow-haskell-users mailing list
 glasgow-haskell-us...@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



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


Re: [Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread Twan van Laarhoven

On 2011-06-27 13:51, Steffen Schuldenzucker wrote:

Could you specify what exactly the function is supposed to do? I am
pretty sure that a function like

seqPeriod :: (Eq a) = [a] - Maybe Integer -- Nothing iff non-periodic

cannot be written.


What about sequences that can be specified in terms of 'iterate':

 import Control.Arrow (first)

 -- Return the non-repeating part of a sequence followed by the repeating part.
 --
 --  iterate f x0 == in  a ++ cycle b
 --   where (a,b) = findCycle f x0
 --
 -- see http://en.wikipedia.org/wiki/Cycle_detection
 findCycle :: Eq a = (a - a) - a - ([a],[a])
 findCycle f x0 = go1 (f x0) (f (f x0))
   where
 go1 x y | x == y= go2 x0 x
 | otherwise = go1 (f x) (f (f y))
 go2 x y | x == y= ([], x : go3 x (f x))
 | otherwise = first (x:) (go2 (f x) (f y))
 go3 x y | x == y= []
 | otherwise = y : go3 x (f y)

 -- diverges if not periodic
 seqPeriod :: Eq a = (a - a) - a - Integer
 seqPeriod f x0 = length . snd $ findCycle f x0


Twan

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


Re: [Haskell-cafe] Period of a sequence

2011-06-27 Thread Richard O'Keefe

On 27/06/2011, at 8:32 PM, Steffen Schuldenzucker wrote:

 
 
 On 06/26/2011 04:16 PM, michael rice wrote:
 MathWorks has the function seqperiod(x) to return the period of sequence
 x. Is there an equivalent function in Haskell?
 
 Could you specify what exactly the function is supposed to do?

Google turns up the documentation pretty quickly.
The period p is computed as the minimum length of a subsequence x(1:p)
 of x that repeats itself continuously every p samples in x.
http://www.mathworks.com/help/toolbox/signal/seqperiod.html
(The misuse of the word continuously is theirs, not mine.)

Incomplete repetitions at the end are allowed, so by that definition
every finite sequence _has_ a period which can be found in quadratic time.

The times I've wanted something like this, the data have been noisy
enough that the implied algorithm would have been guaranteed to be useless.


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


[Haskell-cafe] Enumerators, Enumeratees and Iterators

2011-06-27 Thread Sævar Berg
Hey Café.

I've been playing with Enumerators, Iteratees and Enumeratees today after
having spent a few days writing a server application using lazy IO, then
reading slides from Oleg's DEFUN8 talk notes, and I quote: Lazy IO in
serious, server-side programming is unprofessional, I can talk a lot how
disturbingly, distressingly wrong lazy IO is theoretically, how it breaks
all equational reasoning after which my OCD self has been eating me up to
take a proper look at this, so here I am.

I'm already beginning to see how Iteratees, Enumerators and Enumeratees can
be nifty, but I have a couple of questions about a couple of ideas and
whether, and if so how they can be implemented.

The first question is, I think, to be solved with enumeratees but I can't
really grok how.
Let's say I have an iteratee that consumes all input. Is it possible to
implement an enumeratee or something else to stick between the enumerator
and the iteratee to basically modify the input to the iteratee to only be a
part of the input?

Something like this:

enumFile someFile  printFileLines -- prints file with prepended line
numbers
enumFile someFile ?? onlyGet10Lines  printFileLines -- print only 10
lines

The second question could actually have an application in the server I'm
writing. I was wondering if it was possible to write iteratees/enumerators
that would only generate/consume when a certain something was the next chunk
to be processed? It's a bit hard to explain, but let me try to give you an
example.

Let's say my application takes input from the network which contains
commands that the server reacts to. Let's say I have a list of command
handlers that I want to run this command through, but the handlers will only
execute when they are passed the command that they are responsible for
handling.
Can this list of command handlers be enumerators/iteratees/enumeratees? E.g.
is it possible to 'concat' them, making them each peek at the next chunk to
see if it's theirs to handle and put it back if it isn't?

I know this is possible to do differently and I have an idea for how I would
do this, but I'm wondering if this is possible. If I can get answers to
either or both of the questions it would help me a bit on my way to
completely realize the roles that enumerators vs. iteratees vs. enumeratees
have, as the lines seem a bit blurred -- sometimes, anyway.

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


Re: [Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread Luke Palmer
On Mon, Jun 27, 2011 at 4:25 PM, Twan van Laarhoven twa...@gmail.comwrote:

 On 2011-06-27 13:51, Steffen Schuldenzucker wrote:

 Could you specify what exactly the function is supposed to do? I am
 pretty sure that a function like

 seqPeriod :: (Eq a) = [a] - Maybe Integer -- Nothing iff non-periodic

 cannot be written.


 What about sequences that can be specified in terms of 'iterate':


This is beginning to be reminiscent of the recent paper by Max Bolingbroke,
termination combinators forever (great paper).

http://www.cl.cam.ac.uk/~mb566/papers/termination-combinators-hs11.pdf


  import Control.Arrow (first)

  -- Return the non-repeating part of a sequence followed by the repeating
 part.
  --
  --  iterate f x0 == in  a ++ cycle b
  --   where (a,b) = findCycle f x0
  --
  -- see 
  http://en.wikipedia.org/wiki/**Cycle_detectionhttp://en.wikipedia.org/wiki/Cycle_detection
  findCycle :: Eq a = (a - a) - a - ([a],[a])
  findCycle f x0 = go1 (f x0) (f (f x0))
where
  go1 x y | x == y= go2 x0 x
  | otherwise = go1 (f x) (f (f y))
  go2 x y | x == y= ([], x : go3 x (f x))
  | otherwise = first (x:) (go2 (f x) (f y))
  go3 x y | x == y= []
  | otherwise = y : go3 x (f y)
 
  -- diverges if not periodic
  seqPeriod :: Eq a = (a - a) - a - Integer
  seqPeriod f x0 = length . snd $ findCycle f x0


 Twan


 __**_
 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: [arch-haskell] ghc-7.0.3 haskell-platform

2011-06-27 Thread Magnus Therning
On Thu, Jun 23, 2011 at 05:15:43PM +0300, Vesa Kaihlavirta wrote:
 Hello to all Haskellites,
 
 There's finally an upgraded haskell-platform and corresponding
 packages in extra/ -- reason for the delay was partly lack of
 brainpower (I had some time, but didn't have the energy to work with
 thought). When my summer vacation just started, I got enough quality
 time with the problem and managed to untangle the mess in minutes,
 really.
 
 What happened recently:
 
 - reversed FS#17875, which was alone causing all the trouble :(
 - ghc-7.0.3-2, haskell-platform-2011.2.0.0-4 went into testing repo
 - started moving everything else away from extra to community
 (-testing at first)
   * this is not many packages, I think it's just darcs, haddock and
 their dependencies
 - xmonad, xmonad-contrib and their deps built and uploaded to 
 community-testing
 
 ghc-7.0.4 just came out, which fixes some nasty bugs, but sadly, the
 platform is not there yet.
 
 Rémy was doing some work on automating the whole rebuild process
 (which is currently about 20-30 separate build  install steps when
 doing manually), but I don't know how that went.

I noticed that a rebuild of haskell-hslogger is lingering in
[testing], does it need any more work or can it be pushed into
[extra]/[community]?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
 -- Alan Kay


pgp0yvtQ31Gzk.pgp
Description: PGP signature
___
arch-haskell mailing list
arch-haskell@haskell.org
http://www.haskell.org/mailman/listinfo/arch-haskell


Re: [arch-haskell] Starting to help

2011-06-27 Thread Magnus Therning
On Mon, Jun 27, 2011 at 12:51:18AM +0200, Peter Simons wrote:
 Hi Magnus,
 
   Isn't this still the same workflow you had when you wrote [1]?
 
 no, it's not.

Since I'm curious, what improvements have you made to the tools that
address the inadequacy you reported back then?

Have they just been changes to the scripts found in your personal git
repo?

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus


Perl is another example of filling a tiny, short-term need, and then
being a real problem in the longer term.
 -- Alan Kay


pgpuvRzl8TFZD.pgp
Description: PGP signature
___
arch-haskell mailing list
arch-haskell@haskell.org
http://www.haskell.org/mailman/listinfo/arch-haskell


[arch-haskell] Setup: Can't find transitive deps for haddock with Leksah

2011-06-27 Thread Mathew de Detrich
Ok, so once again I have tried to compile/install leksah (
http://hackage.haskell.org/package/leksah) with Haskell when using
cabal2arch, and just after the package is 'built' (but not yet finalized) I
get this error message

Configuring leksah-0.10.0.4...
Preprocessing library leksah-0.10.0.4...
Preprocessing executables for leksah-0.10.0.4...
Building leksah-0.10.0.4...
Registering leksah-0.10.0.4...
Linking dist/build/leksah/leksah ...
Running Haddock for leksah-0.10.0.4...
Preprocessing library leksah-0.10.0.4...
Preprocessing executables for leksah-0.10.0.4...
Setup: Can't find transitive deps for haddock

Doing a google search, I found that this error has occurred in other places,
but only in build log fails for hackagedb packages

Note that the .cabal file for Leksah (incorrectly) has enable-shared one of
the ghc build options, this needs to be removed for the package to build
correctly (up until this error anyways); as well as the issue outlined below
 (see
http://answerpot.com/showthread.php?2552829-Build+error+with+lekash+on+archlinux+when+using+cabal2arch
for
more info). I have attached a correct PKGBUILD/.install file in this email

There also seems to be another error with cabal2arch, that puts
the dependency haskell-leksah within the actual haskell-leksah package (of
the same version as well) inside the PKGBUILD. I just removed
that dependency from PKGBUILD to build leksah


PKGBUILD
Description: Binary data


haskell-leksah.install
Description: Binary data
___
arch-haskell mailing list
arch-haskell@haskell.org
http://www.haskell.org/mailman/listinfo/arch-haskell