Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-28 Thread Nicolas Wu
On Wed, Nov 28, 2012 at 8:36 PM, Jeff Shaw shawj...@gmail.com wrote:
 On 11/27/2012 4:59 PM, Nicolas Wu wrote:
 I pulled the latest version of HDBC-odbc, and it appears to be working MUCH
 better than before. I now have 0% timeouts from httperf with 50
 connections/second and timeout set to 0.1 seconds. It's looking like the
 safe imports vastly improved IO blocking. I haven't seen any new problems
 since the new version went live.

That's great to hear! I'll aim to push this version to Hackage over the weekend.

Nick

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


Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-27 Thread Nicolas Wu
On Tue, Nov 27, 2012 at 9:45 PM, Jeff Shaw shawj...@gmail.com wrote:
 On 11/27/2012 2:45 PM, Gershom Bazerman wrote:

 HDBC-odbc has long used the wrong type of FFI imports, resulting in
 long-running database queries potentially blocking all other IO. I just
 checked, and apparently a patch was made to the repo in September that
 finally fixes this [1], but apparently a new release has yet to be uploaded
 to hackage. In any case, if you try to install it from the repo, this may at
 least solve some of your problems.

 [1]
 https://github.com/hdbc/hdbc-odbc/commit/7299d3441ce2e1d5a485fe79b37540c0a44a44d4

 --Gershom

 Gershom, Thanks for pointing this out. I've checked out the latest hdbc-odbc
 code, and I'll see if there's an improvement.

Hi, I'm the maintainer of HDBC. I haven't yet released this code since
it hasn't yet been fully tested. However, if you're happy with it,
I'll push the version with proper ffi bindings up to Hackage.

Nick

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


[Haskell-cafe] Oxford Haskell Users Group

2012-10-22 Thread Nicolas Wu
Dear all,

After a long pause over the summer, the Oxford Haskell Users Group
will be meeting this week, at 8pm on Friday 26th October, at the Mitre
pub on High Street, Oxford [1].

The group meets in an informal setting with no real agenda: typically
we turn up, have a few pints, and enjoy a good chat about what we've
been doing with Haskell. If you'd like to have more details about our
meetings, then join our mailing list [2], where our meetings are
usually announced.

The format of OxHUG will be changing slightly: we'll be meeting once a
month rather than fortnightly, and rotating the day of the week. The
full details of the meetings can be found on the OxHUG calendar [3],
though at the moment only this week's meeting is planned.

Nick

[1]: http://goo.gl/maps/QEN3o
[2]: https://groups.google.com/group/oxhug
[3]: 
https://www.google.com/calendar/embed?src=pjc31qnpq48rvvncq72utqtang%40group.calendar.google.comctz=Europe/London

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


Re: [Haskell-cafe] Cabal problem re. haskelldb-hdbc-mysql

2012-07-05 Thread Nicolas Wu
On Wed, Jul 4, 2012 at 3:58 PM, Yves Parès yves.pa...@gmail.com wrote:
 Hi,
 the package http://hackage.haskell.org/package/haskelldb-hdbc-mysql/ the use
 of HDBC 2.3.0
 I'm using cabal-install 0.14, and with a fresh install (no packages already
 installed), cabal-install tries to install HDBC-2.1.1 instead of, say,
 HDBC-2.2.7.0.

 The problem is that HDBC-2.1.1 is old (2009) and does not compile.

 When I download haskelldb-hdbc-mysql manually, change the dependency and
 then install, it compiles fine.

 Is the dependency ill-declared, or is that a cabal problem?

Apart from the change of license, there were no serious changes to the
HDBC interface between the 2.2.* and 2.3.* series: as far as I know,
it should be fine to change the dependency. That said, I've not worked
with haskelldb-hdbc-mysql, so I can't say for sure.

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


[Haskell-cafe] Oxford Haskell Users Group

2012-05-10 Thread Nicolas Wu
Dear all,

I'd like to announce that the Oxford Haskell User's Group will be
meeting up next week at 7pm on Tuesday 15th May. As is our custom,
we'll be catching up over a few drinks in a local pub, this time, it's
at the Three Goats Heads, St Michael's Street. Discussion is informal,
with the occasional presentation about some interesting aspect of
Haskell. All are welcome!

If you'd like to be kept up to date about future meetings, which are
roughly once a week during term time, then do join our mailing list,
which can be found under OxHUG at google groups [1].

All the best,

Nick

[1]: http://groups.google.com/group/oxhug

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


Re: [Haskell-cafe] Vim plugin for ghc-mod

2012-02-16 Thread Nicolas Wu
On 16 February 2012 08:51, Kazu Yamamoto k...@iij.ad.jp wrote:
 eagletmt implemented a Vim plugin for ghc-mod:

        https://github.com/eagletmt/ghcmod-vim

 Happy Haskell programming on Vim!

Note that there's also support for ghc-mod using [syntastic][1] for
vim, which is well supported for Haskell and other languages too.

Nick

[1]: https://github.com/scrooloose/syntastic

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


Re: [Haskell-cafe] difference between class context and deriving

2011-08-02 Thread Nicolas Wu
Hi Patrick,

On 2 August 2011 13:57, Patrick Browne patrick.bro...@dit.ie wrote:
 What is the difference between using a class context and deriving in
 data type declaration?

A class context simply says something about the types involved in the
construction. In your example,

 data Eq a = Set1 a = NilSet1 | ConsSet1 a (Set1 a)

the type `a` must have an instance of `Eq`. This does not imply that
`Set1` itself has an instance of `Eq`.

On the other hand, the `deriving` keyword tells the compiler that
you'd like it to try and derive a default instance for a class. In
your example, this results in an instance of `Eq Set2`.

Hopefully that should explain why you had:

 (NilSet1) == (NilSet1) -- no instance, error
 (NilSet2) == (NilSet2) -- True

All the best,

Nick

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


[Haskell-cafe] Haskell Parallel Digest 4

2011-07-22 Thread Nicolas Wu
 speedup (3 June 2011)][12]

While reading Simon Marlow's [tutorial][19] on parallel and
concurrent programming, John Ramsdell reported some remarkable
(slightly superlinear!) performance gains for one of his programs.
Thomas Schilling guessed that this was due to the large variance
in the figures reported, but went on to describe how it might be
possible to obvserve such performance boosts due to reduced local
cache misses when using several cores. Without more information
about the program in question, it's difficult to do any kind of
diagnosis, but nevertheless, it's great to hear about good results
from a happy Haskeller!

* [Automatic Reference Counting (2 July 2011)][13]

After hearing about the new static analysis tools in Clang that
does automatic reference counting (ARC), Thomas Davie was
wondering if some compiler gurus might be able to comment on the
applicability of this kind of analysis to Haskell, as an
alternative to garbage collection. This led to an enlightening
discussion about reference counting versus garbage collection.

* [Haskell on NUMA (16 June 2011)][14]

Michael Lesniak was wondering what the state of parallel
performance of Haskell on Non-Uniform Memory Access (NUMA)
machines was like, since he's having problems and can't find much
useful information online. Nobody seems to have answered this one,
are there any suggestions?

* [Parallel compilation and execution? (26 May 2011)][15]

Michael Rice was trying to figure out how to compile and run a
simple program that outputs the result of a parallel fibonacci
algorithm. After a quick reminder to use `pseq` rather than `seq`
to force sequential evaluation, Daniel Fischer suggested that
recompilation might be required, and that passing
`--fforce-recomp` would be a good way to ensure that this occurred.

Michael was also keen to know whether Control.Parallel was
comparable to OpenMP. Alex Mason gave a detailed reply and gave an
example of parallel mergesort as a means of comparison.

* [parMap doesn't work fine (12 May 2011)][16]

After just starting out with parallel computations in Haskell,
Grigory Sarnitskiy ran into troubles making parMap work with lazy
structures. To resolve these issues, Brandon Moore pointed to
using `rdeepseq`, and Maciej Piechotka suggested `deepseq`.

* [efficient parallel foldMap for lists/sequences (17 June 2011)][17]

Sebastian Fischer re-posted his question about efficient parallel
`foldMap` for lists to the parallel mailing list. In essence he
was seeking an efficient implementation of `foldMap`, where a list
is folded into a single value before a map is applied to the
result. Johannes Waldmann advised against using ordinary lists,
and mentioned that he was using `Data.Vector` instead.
Additionally, he recommended switching to a sequential fold once a
parallel fold had been used to a certain depth. Christopher Brown
further confirmed that it was a good idea to spark off
computations when the granularity is high enough to make it
worthwhile, and also mentioned that it was best to spark
computations that were evaluated to normal form.

* [Wanted: parallel Haskell tutorial/talk/demonstration in Leipzig, 
Germany, October 7 (8 July 2011)][18]


Johannes Waldmann is looking for volunteers who might be able to
present at their local Haskell Workshop, and welcomes submissions
on parallel and distributed computing using Haskell. The
submission deadline is 20 August.

Stack Overflow
--

* [How to write nested loop problem using parallel strategies in Haskell][8]
* [How to measure sequential and parallel runtimes of Haskell program][9]
* [Poor performance / lockup with STM][10]

Help and Feedback
--

If you'd like to make an announcement in the next Haskell Parallel
Digest, then get in touch with me, Nicolas Wu, at
paral...@well-typed.com. Please feel free to leave any comments and
feedback!

[0]: http://www.haskell.org/haskellwiki/Parallel_GHC_Project
[1]: http://research.microsoft.com/apps/pubs/default.aspx?id=138042
[2]: http://hackage.haskell.org/package/parallel
[3]: http://tomasp.net/blog/comprefun.aspx
[4]: 
http://jaspervdj.be/posts/2011-07-05-parallelizing-a-nonogram-solver.html

[5]: http://blog.ezyang.com/2011/06/the-iva-monad/
[6]: 
http://themonadreader.wordpress.com/2011/07/11/call-for-copy-issue-19-special-issue-on-parallelism-and-concurrency/

[7]: http://themonadreader.files.wordpress.com/2011/07/issue18.pdf
[8]: 
http://stackoverflow.com/questions/6444716/how-to-write-nested-loop-problem-using-parallel-strategies-in-haskell
[9]: 
http://stackoverflow.com/questions/6623316/how-to-measure-sequential-and-parallel-runtimes-of-haskell-program
[10]: 
http://stackoverflow.com

[Haskell-cafe] Haskell Parallel Digest 3

2011-06-16 Thread Nicolas Wu

Parallel Haskell Digest
===
Edition 3
2011-06-16
http://www.well-typed.com/blog/55

Hello Haskellers!

Welcome to the third edition of the Parallel Haskell Digest, bringing
you news, discussions and tasters of parallelism and concurrency in
Haskell. The digest is made possible by the Parallel GHC project.
More news about how we're doing below.

This digest is brought to you by Eric Kow and Nicolas Wu. Nick will
be taking over as maintainer of the Parallel Digest for the next few
months.

It's tutorial season in the Parallel Haskell world, with Simon
Marlow's [Parallel and Concurrent Programming in Haskell][1], and Don
Stewart's [Numeric Haskell: A Repa Tutorial][2]. The former gives a
broad tour of parallelism and concurrency techniques in Haskell and
the latter focuses on the Repa parallel array library. Both are very
concrete and focus on real working code. Give them a try!

News
--
* Haskell in the Economist! The Economist article [Parallel Bars][3]
discusses the rise of multicore computing, and the essential
obstacle that programs have to be specially written with parallelism
in mind. The article gives a tour of some problems (overhead and
dependencies between subtasks, programmers being trained for
sequential programming, debugging parallel programs) and possible
solutions, among which is functional programming:


Meanwhile, a group of obscure programming languages used in
academia seems to be making slow but steady progress, crunching
large amounts of data in industrial applications and behind the
scenes at large websites. Two examples are Erlang and Haskell,
both of which are “functional programming” languages.


Are we doomed to succeed?


Word of the Month
--
The word of the month (well, phrase really!) for this digest is
*parallel arrays*. Parallel array manipulation fits nicely into
Haskell's arsenal of parallel processing techniques. In fact, you
might have seen the Repa library, as mentioned above, in the news
a while back. And now there's a new tutorial on the [Haskell Wiki][2].
So what's all the fuss?

Parallel arrays manipulation is a particularly nice way of writing
parallel programs: it's pure and it has the potential to scale very
well to large numbers of CPUs. The main limitation is that not all
programs can be written in this style. Parallel arrays are a way of
doing *data parallelism* (as opposed to *control parallelism*).

Repa (REgular Parallel Arrays) is a Haskell library for high
performance, regular, multi-dimensional parallel arrays. All numeric
data is stored unboxed and functions written with the Repa combinators
are automatically parallel. This means that you can write simple array
code and get parallelism for free.

As an example, Repa has been used for real time edge detection using a
[Canny edge algorithm][12], which has resulted in performance
comparable to the standard OpenCV library, an industry standard
library of computer vision algorithms written in C and C++ (a single
threaded Haskell implementation is about 4 times slower than the
OpenCV implementation, but is on par when using 8 threads on large
images).

While the Canny algorithm written with Repa doesn't quite match the
speed of its procedural counterparts, it benefits from all of
Haskell's built in support for purity and type safety, and painlessly
scales to multiple cores. You can find more details on Ben Lippmeier's
[blog][10].


Parallel GHC project news
--
The Parallel GHC Project is an MSR-funded project to promote the
real-world use of parallel Haskell. Part of this project involves
effort by Well-Typed to provide tools for use by the general
community.

Last week, Well-Typed were excited to [announce][11] that we have
capacity to support another partner for the parallel project for at
least another 12 months. So, if you have a project that involves
scaling up to multiple cores, or that deals with some heavy duty
concurrency, then we'd love to hear from you. In return for your time
and commitment to the parallel project, we'll unleash our team of
expert programmers to help build tools and provide support that will
help you and the community towards making parallel Haskell even more
accessible.

For more information on the Parallel GHC project,
on the [Parallel GHC Project wiki page][27].

Blogs, papers and packages
--
* [Parallel and Concurrent Programming in Haskell (19 May)][1]

Simon Marlow released version 1.1 of his tutorial introducing the
main programming models available for concurrent and parallel
programming in Haskell. This tutorial takes a deliberately
practical approach: most of the examples are real Haskell programs
that you can compile, run, measure, modify and experiment with. The
tutorial covers

Re: [Haskell-cafe] Comment Syntax

2011-06-06 Thread Nicolas Wu
This whole discussion is reminding me of Wadler's Law of Language
Design [1], it's nice to see that in 15 years things haven't changed
much!

   WADLER'S LAW OF LANGUAGE DESIGN
   In any language design, the total time spent discussing
   a feature in this list is proportional to two raised to
   the power of its position.
0. Semantics
1. Syntax
2. Lexical syntax
3. Lexical syntax of comments

[1] http://www.informatik.uni-kiel.de/~curry,/listarchive/0017.html

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


Re: [Haskell-cafe] License of hslogger, HDBC, etc.

2011-06-02 Thread Nicolas Wu
On 2 June 2011 22:20, John Goerzen jgoer...@complete.org wrote:
 Hi Jon  all,

 I've decided that I'm OK with re-licensing hslogger, HDBC, and well all of
 my Haskell libraries (not end programs) under 3-clause BSD.

Awesome, thanks very much!

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


Re: [Haskell-cafe] Server hosting

2011-05-07 Thread Nicolas Wu
 Then again,
 I haven't found many companies that list prices in GBP.)

I use rackhost.co.uk I've had no problems with them at all, and they
charge in GBP. A cheaper alternative is CheapVPS, I moved away from
them since they're not terribly reliable, but probably good enough for
personal websites.

Nick

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


Re: [Haskell-cafe] Server hosting

2011-05-07 Thread Nicolas Wu
On 7 May 2011 13:52, Nicolas Wu nicolas...@gmail.com wrote:
 Then again,
 I haven't found many companies that list prices in GBP.)

 I use rackhost.co.uk

Oops, I mean rackspace.co.uk, who I believe are the people behind
slicehost.com which comes highly recommended.

Nick

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


Re: [Haskell-cafe] The Haskell theme

2010-10-13 Thread Nicolas Wu
On 13 October 2010 07:41, Christopher Done chrisd...@googlemail.com wrote:
 This reminds me, do we have a good syntax highlighting theme?
 HsColour's has always been pretty bad (no offence intended -- but
 there is a reason people always redefine it).

I've been sitting on a post about highlighting Haskell for a while now
which is about Haskell syntax highlighting in HTML files [1]. This
would let you use any CSS style file from SHJS [2], and does a pretty
good job of highlighting Haskell. Feel free to use the style file on
my website if you like it.

Nick

[1] http://zenzike.com/posts/2010-10-14-highlighting-haskell-with-shjs/
[2] http://shjs.sourceforge.net/css/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lambda-case / lambda-if

2010-10-05 Thread Nicolas Wu
 To repeat, the analogues in SML and Erlang *do* support multiple
 clauses (as well as pattern matching) and the failure of Haskell
 lambdas to do so has always seemed like a weird restriction in a
 language that's usually free of weird restrictions.

I agree with this sentiment. I have never understood why lambdas can't
handle multiple clauses.

 I'd prefer to see something like
        \ 1 - f
        | 2 - g
 but I'm sure something could be worked out.

This sounds sensible, since the lambda-case clause should really be
about having a lambda with support for cases, not a case statement
that's implicitly surrounded by a lambda. While I think the case of
is a good idea, multiple clauses in lambdas seems more canonical to
me.

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


Re: [Haskell-cafe] The where-clause and guards

2010-07-21 Thread Nicolas Wu
There's nothing wrong with the use of your example, I'm guessing it's
something in your ... that's leading to the parse error. This compiles
just fine:

f a b
 | c  1  = 1
 | c  1  = 2
 | otherwise  = 3
 where c = a+b

Nick


On Wed, Jul 21, 2010 at 8:01 AM, Eitan Goldshtrom
thesource...@gmail.com wrote:
 I'm trying to fit a where clause to some guards I'm using. I have the
 following

 f a b
  | c  1      = ...
  | c  1      = ...
  | otherwise  = ...
  where c = a+b

 yet I'm getting a parsing error. Is this not the correct way to combine
 where with guards?

 -Eitan
 ___
 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] The where-clause and guards

2010-07-21 Thread Nicolas Wu
As I understand the use of where clauses in [1], A where clause is
only allowed at the top level of a set of equations or case
expression, would mean that the first where is scoping over the
whole traceRay function: the where m = shouldn't be there, since
there's already a where clause in scope.

Try this:

traceRay (x,y) r@((cx,cy,cz):n) (vx,vy,vz) iter
   | m  100= do
   color $ Color3 (sin vx) (cos vy) (cos vz)
   vertex $ Vertex2 x y
   | otherwise  = do
   [boxx,boxy,boxz] - boxFold [vx,vy,vz]
   (ballx,bally,ballz) - ballFold (boxx,boxy,boxz)
   traceRay (x, y) r (2*ballx + cx, 2*bally + cy, 2*ballz + cz) (iter-1)
   where
   boxFold [] = return []
   boxFold (a:b)
   | a  2= do
   rem - boxFold b
   return $ (2-a):rem
   | a  (-2) = do
   rem - boxFold b
   return $ (-2-a):rem
   |otherwise = do
   rem - boxFold b
   return $ (a):rem
   ballFold (x,y,z)
   | n  0.5   = return (4*x, 4*y, 4*z)
   | n  1 = return (x/(n*n), y/(n*n), z/(n*n))
   | otherwise = return (x, y, z)
   where n = sqrt $ x*x + y*y + z*z
   m = sqrt $ vx*vx + vy*vy + vz*vz



[1] http://www.haskell.org/tutorial/patterns.html

On Wed, Jul 21, 2010 at 8:38 AM, Eitan Goldshtrom
thesource...@gmail.com wrote:
 Well, perhaps you can help me figure out the problem with my exact program.
 Just in case it matters, the program draws a Mandelbox via volumetric ray
 casting. I can provide more information about the function, but I wouldn't
 think it's necessary, since my problem is with parsing. The error I'm
 getting is with the where-clause at the very bottom:

 traceRay (x,y) r@((cx,cy,cz):n) (vx,vy,vz) iter
    | m  100        = do
        color $ Color3 (sin vx) (cos vy) (cos vz)
        vertex $ Vertex2 x y
    | otherwise      = do
        [boxx,boxy,boxz] - boxFold [vx,vy,vz]
        (ballx,bally,ballz) - ballFold (boxx,boxy,boxz)
        traceRay (x, y) r (2*ballx + cx, 2*bally + cy, 2*ballz + cz) (iter-1)
        where
            boxFold [] = return []
            boxFold (a:b)
                | a  2        = do
                    rem - boxFold b
                    return $ (2-a):rem
                | a  (-2)     = do
                    rem - boxFold b
                    return $ (-2-a):rem
                |otherwise     = do
                    rem - boxFold b
                    return $ (a):rem
            ballFold (x,y,z)
                | n  0.5       = return (4*x, 4*y, 4*z)
                | n  1         = return (x/(n*n), y/(n*n), z/(n*n))
                | otherwise     = return (x, y, z)
                where n = sqrt $ x*x + y*y + z*z
    where m = sqrt $ vx*vx + vy*vy + vz*vz

 On 7/21/2010 3:13 AM, Nicolas Wu wrote:

 There's nothing wrong with the use of your example, I'm guessing it's
 something in your ... that's leading to the parse error. This compiles
 just fine:

 f a b
  | c  1      = 1
  | c  1      = 2
  | otherwise  = 3
  where c = a+b

 Nick


 ___
 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] The where-clause and guards

2010-07-21 Thread Nicolas Wu
Ugh, my formatting got eaten up by gmail. I just removed the where in
front of m =, and aligned tat statment with your ballFold
definition. I would also align the first where statement with the case
bars of traceRay.

Nick

On Wed, Jul 21, 2010 at 8:53 AM, Nicolas Wu nicolas...@gmail.com wrote:
 As I understand the use of where clauses in [1], A where clause is only 
 allowed at the top level of a set of equations or case expression, would 
 mean that the first where is scoping over the whole traceRay function: the 
 where m = shouldn't be there, since there's already a where clause in scope.

 Try this:

 traceRay (x,y) r@((cx,cy,cz):n) (vx,vy,vz) iter
 | m  100 = do
 color $ Color3 (sin vx) (cos vy) (cos vz)
 vertex $ Vertex2 x y
 | otherwise = do
 [boxx,boxy,boxz] - boxFold [vx,vy,vz]
 (ballx,bally,ballz) - ballFold (boxx,boxy,boxz)
 traceRay (x, y) r (2*ballx + cx, 2*bally + cy, 2*ballz + cz) (iter-1)
 where
 boxFold [] = return []
 boxFold (a:b)
 | a  2 = do
 rem - boxFold b
 return $ (2-a):rem
 | a  (-2) = do
 rem - boxFold b
 return $ (-2-a):rem
 |otherwise = do
 rem - boxFold b
 return $ (a):rem
 ballFold (x,y,z)
 | n  0.5 = return (4*x, 4*y, 4*z)
 | n  1 = return (x/(n*n), y/(n*n), z/(n*n))
 | otherwise = return (x, y, z)
 where n = sqrt $ x*x + y*y + z*z
 m = sqrt $ vx*vx + vy*vy + vz*vz



 [1] http://www.haskell.org/tutorial/patterns.html

 On Wed, Jul 21, 2010 at 8:38 AM, Eitan Goldshtrom thesource...@gmail.com 
 wrote:
 Well, perhaps you can help me figure out the problem with my exact program.
 Just in case it matters, the program draws a Mandelbox via volumetric ray
 casting. I can provide more information about the function, but I wouldn't
 think it's necessary, since my problem is with parsing. The error I'm
 getting is with the where-clause at the very bottom:

 traceRay (x,y) r@((cx,cy,cz):n) (vx,vy,vz) iter
    | m  100        = do
        color $ Color3 (sin vx) (cos vy) (cos vz)
        vertex $ Vertex2 x y
    | otherwise      = do
        [boxx,boxy,boxz] - boxFold [vx,vy,vz]
        (ballx,bally,ballz) - ballFold (boxx,boxy,boxz)
        traceRay (x, y) r (2*ballx + cx, 2*bally + cy, 2*ballz + cz) (iter-1)
        where
            boxFold [] = return []
            boxFold (a:b)
                | a  2        = do
                    rem - boxFold b
                    return $ (2-a):rem
                | a  (-2)     = do
                    rem - boxFold b
                    return $ (-2-a):rem
                |otherwise     = do
                    rem - boxFold b
                    return $ (a):rem
            ballFold (x,y,z)
                | n  0.5       = return (4*x, 4*y, 4*z)
                | n  1         = return (x/(n*n), y/(n*n), z/(n*n))
                | otherwise     = return (x, y, z)
                where n = sqrt $ x*x + y*y + z*z
    where m = sqrt $ vx*vx + vy*vy + vz*vz

 On 7/21/2010 3:13 AM, Nicolas Wu wrote:

 There's nothing wrong with the use of your example, I'm guessing it's
 something in your ... that's leading to the parse error. This compiles
 just fine:

 f a b
  | c  1      = 1
  | c  1      = 2
  | otherwise  = 3
  where c = a+b

 Nick


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



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


[Haskell-cafe] Kate: Haskell and Literate Haskell syntax files

2010-06-30 Thread Nicolas Wu
Dear all,

I've just finished implementing a complete rewrite of the Haskell and
Literate Haskell files for Kate. This improves the previous version in
many ways:

* Operators are now supported (++, !, =, and any other combination
of legal operator characters)
* Special symbols are recognised (=, -, -, ::, ..)
* Unicode support for  →, ←, ∷, ‥,⇒, ∀, ∃
* Support for qualified module functions (List.sort, etc)
* Support for qualified module types
* Refactored Literate Haskell using IncludeRules
* Support for literate code (using  and \begin{code} \end{code})
* Support for literate specifications (using  and \begin{spec} \end{spec})

You can find the most recent snapshot in my github repository [1], and
examples of highlighted syntax using these files at my website [2].

Please let me know if there are any further improvements you can think of,

Nick

[1] http://github.com/zenzike/kate-haskell
[2] http://zenzike.com
?xml version=1.0 encoding=UTF-8?
!DOCTYPE language SYSTEM language.dtd
language name=Haskell version=2.0.2 kateversion=2.3 section=Sources extensions=*.hs mimetype=text/x-haskell author=Nicolas Wu (zenz...@gmail.com) license=LGPL indenter=haskell
  highlighting
  list name=keywords
item as /item
item case /item
item class /item
item data /item
item deriving /item
item do /item
item else /item
item hiding /item
item if /item
item import /item
item in /item
item infixl /item
item infixr /item
item instance /item
item let /item
item module /item
item newtype /item
item of /item
item primitive /item
item qualified /item
item then /item
item type /item
item where /item
  /list
  list name=prelude function
item FilePath /item
item IOError /item
item abs /item
item acos /item
item acosh /item
item all /item
item and /item
item any /item
item appendFile /item
item approxRational /item
item asTypeOf /item
item asin /item
item asinh /item
item atan /item
item atan2 /item
item atanh /item
item basicIORun /item
item break /item
item catch /item
item ceiling /item
item chr /item
item compare /item
item concat /item
item concatMap /item
item const /item
item cos /item
item cosh /item
item curry /item
item cycle /item
item decodeFloat /item
item denominator /item
item digitToInt /item
item div /item
item divMod /item
item drop /item
item dropWhile /item
item either /item
item elem /item
item encodeFloat /item
item enumFrom /item
item enumFromThen /item
item enumFromThenTo /item
item enumFromTo /item
item error /item
item even /item
item exp /item
item exponent /item
item fail /item
item filter /item
item flip /item
item floatDigits /item
item floatRadix /item
item floatRange /item
item floor /item
item fmap /item
item foldl /item
item foldl1 /item
item foldr /item
item foldr1 /item
item fromDouble /item
item fromEnum /item
item fromInt /item
item fromInteger /item
item fromIntegral /item
item fromRational /item
item fst /item
item gcd /item
item getChar /item
item getContents /item
item getLine /item
item group /item
item head /item
item id /item
item inRange /item
item index /item
item init /item
item intToDigit /item
item interact /item
item ioError /item
item isAlpha /item
item isAlphaNum /item
item isAscii /item
item isControl /item
item isDenormalized /item
item isDigit /item
item isHexDigit /item
item isIEEE /item
item isInfinite /item
item isLower /item
item isNaN /item
item isNegativeZero /item
item isOctDigit /item
item isPrint /item
item isSpace /item
item isUpper /item
item iterate /item
item last /item
item lcm /item
item length /item
item lex /item
item lexDigits /item
item lexLitChar /item
item lines /item
item log /item
item logBase /item
item lookup /item
item map /item
item mapM /item
item mapM_ /item
item max /item
item maxBound /item
item maximum /item
item maybe /item
item min /item
item minBound /item
item minimum /item
item mod /item
item negate /item
item not /item
item notElem /item
item null /item
item numerator /item
item odd /item
item or /item
item ord /item
item otherwise /item
item pack /item
item pi /item
item pred /item
item primExitWith /item
item print /item
item product /item
item properFraction /item
item putChar /item
item putStr /item
item putStrLn /item
item quot /item
item quotRem /item
item range /item
item rangeSize /item
item read /item
item readDec /item
item readFile /item
item readFloat /item
item readHex

Re: [Haskell-cafe] little help please

2010-03-18 Thread Nicolas Wu
This compiles:

import System.Environment(getArgs)
import System.Process(readProcessWithExitCode)
import System.Exit(exitWith,ExitCode(ExitSuccess))

main = do
  args - getArgs
  (ecode,out,err) - readProcessWithExitCode
c:\\Perl64\\bin\\perl.exe (C:\\Program
Files\\MySQL\\scripts\\mysql_config.pl : args) 
  if ecode == ExitSuccess
then return out
else return err
  exitWith ecode

I had trouble with the spacing you had when I pasted your code, and
also changed the imports so that ExitSuccess was being imported.

All the best,

Nick

On Thu, Mar 18, 2010 at 6:46 PM, Roderick Ford develo...@live.com wrote:
 this will be EASY for you to fix, I am sure... what the heck am I doing
 wrong:
 import System.Environment(getArgs)
 import System.Process(readProcessWithExitCode)
 import System.Exit(exitWith)
 main = do
 args - getArgs
 (ecode,out,err) - readProcessWithExitCode c:\\Perl64\\bin\\perl.exe
 (C:\\Program Files\\MySQL\\scripts\\mysql_config.pl : args) 
 if ecode == System.Exit.ExitCode.ExitSuccess
 then return out
 else return err
         exitWith ecode


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


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


[Haskell-cafe] [patch] lhaskell.vim update

2009-06-29 Thread Nicolas Wu
I have made some modifications to the lhaskell.vim (v1.04) file to add
a feature, and fix up some bugs. I don't know if this is the right
place to post for patches, but the file I have claims that the
haskell-cafe is the maintainer.

First, I made it so that \begin{spec} and \end{spec} environments are
recognised. This helps those of us who use lhs2TeX to document files.

Second, I've fixed up the highlighting where inline Haskell between
bars | used to be mistaken for verbatim text.

There's also a small fix to handle \begin{code} \end{code} tags better.

The modified file is attached.


lhaskell.vim
Description: application/octetstream
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe