[Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Dear list,

From ghc 7.0.1 release notes:

 The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: quoteType 
 and quoteDec.

Some of my code needs to be conditionally compiled to support both
version 6 and 7, what is the recommended way to do it?

ref:

* http://new-www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html

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



Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Thanks Michael,

So the user should use `cabal install --flags -ghc7 package-name` to
install the package, if I'm not mistaken?

Will it work if the package is installed as a dependency? Will the
flag environment be passed down from the root package?

Is there a way to detect GHC version automatically?

: )

Best,


On Sun, Nov 28, 2010 at 1:32 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Sat, Nov 27, 2010 at 6:59 PM, Jinjing Wang nfjinj...@gmail.com wrote:
 Dear list,

 From ghc 7.0.1 release notes:

 The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: 
 quoteType and quoteDec.

 Some of my code needs to be conditionally compiled to support both
 version 6 and 7, what is the recommended way to do it?

 ref:

 * 
 http://new-www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html

 Hi Jinjing,

 I've done this in Yesod. I'm not sure if it's the best way, but
 basically I've added a ghc7 flag to the cabal file, and a block for
 the library that reads:

    if flag(ghc7)
        build-depends:   base                      = 4.3        5
        cpp-options:     -DGHC7
    else
        build-depends:   base                      = 4          4.3

 Then whenever I want to quasi-quote in the code, I write:

 #if GHC7
    [quasiquoter|
 #else
    [$quasiquoter|
 #endif

 Michael




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


Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Sorry, should be `cabal install --flags=ghc7 package-name`.

On Sun, Nov 28, 2010 at 1:59 AM, Jinjing Wang nfjinj...@gmail.com wrote:
 Thanks Michael,

 So the user should use `cabal install --flags -ghc7 package-name` to
 install the package, if I'm not mistaken?

 Will it work if the package is installed as a dependency? Will the
 flag environment be passed down from the root package?

 Is there a way to detect GHC version automatically?

 : )

 Best,


 On Sun, Nov 28, 2010 at 1:32 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Sat, Nov 27, 2010 at 6:59 PM, Jinjing Wang nfjinj...@gmail.com wrote:
 Dear list,

 From ghc 7.0.1 release notes:

 The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: 
 quoteType and quoteDec.

 Some of my code needs to be conditionally compiled to support both
 version 6 and 7, what is the recommended way to do it?

 ref:

 * 
 http://new-www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html

 Hi Jinjing,

 I've done this in Yesod. I'm not sure if it's the best way, but
 basically I've added a ghc7 flag to the cabal file, and a block for
 the library that reads:

    if flag(ghc7)
        build-depends:   base                      = 4.3        5
        cpp-options:     -DGHC7
    else
        build-depends:   base                      = 4          4.3

 Then whenever I want to quasi-quote in the code, I write:

 #if GHC7
    [quasiquoter|
 #else
    [$quasiquoter|
 #endif

 Michael




 --
 jinjing




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


Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Hi Michael, you are absolutely correct, cabal did set the flags automatically.

To sum up, here's what needs to be done:

* add `flag ghc7` as a field in cabal
* add:

if flag(ghc7)
build-depends:   base  = 4.35
cpp-options: -DGHC7
else
build-depends:   base  = 4  4.3

   in library field in cabal

* add `{-# LANGUAGE CPP #-}` in source file
* add

#if GHC7
x

#else
y

#endif


 Hi Antonine, I don't know how to not set those fields in the
constructor.. as a QQ noob, I'm just hacking on some legacy code. This
code doesn't compile in GHC7, so I have to do this trick.

* https://github.com/nfjinjing/mps/blob/master/src/MPS/TH.hs

Best,

On Sun, Nov 28, 2010 at 3:48 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Sat, Nov 27, 2010 at 9:41 PM, Antoine Latter aslat...@gmail.com wrote:
 On Sat, Nov 27, 2010 at 10:59 AM, Jinjing Wang nfjinj...@gmail.com wrote:
 Dear list,

 From ghc 7.0.1 release notes:

 The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: 
 quoteType and quoteDec.

 Some of my code needs to be conditionally compiled to support both
 version 6 and 7, what is the recommended way to do it?

 ref:

 * 
 http://new-www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html

 Can you just not set those fields? Then the code should work as-is for
 both versions. You'll get warnings for GHC 7, I think.

 Sorry Jinjing, I didn't read your original email carefully enough.
 Antoine is absolutely correct, this is the better way to deal with
 defining a quasiquoter. My suggestion is only necessary if you want to
 *use* a quasiquoter.

 Michael




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


Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Hi Antoine, Thanks for pointing out, it did work.

By using a record style constructor, the code can be made to support
both version, something like

here = QuasiQuoter
  {
quoteExp = (litE . stringL)
  , quotePat = (litP . stringL)
  }

in GHC7 there's a warning:

   Warning: Fields of `QuasiQuoter' not initialised: quoteType, quoteDec

So far it works without problem.


On Sun, Nov 28, 2010 at 10:38 AM, Jinjing Wang nfjinj...@gmail.com wrote:
 Hi Michael, you are absolutely correct, cabal did set the flags automatically.

 To sum up, here's what needs to be done:

 * add `flag ghc7` as a field in cabal
 * add:

    if flag(ghc7)
        build-depends:   base                      = 4.3        5
        cpp-options:     -DGHC7
    else
        build-depends:   base                      = 4          4.3

   in library field in cabal

 * add `{-# LANGUAGE CPP #-}` in source file
 * add

    #if GHC7
    x

    #else
    y

    #endif


  Hi Antonine, I don't know how to not set those fields in the
 constructor.. as a QQ noob, I'm just hacking on some legacy code. This
 code doesn't compile in GHC7, so I have to do this trick.

 * https://github.com/nfjinjing/mps/blob/master/src/MPS/TH.hs

 Best,

 On Sun, Nov 28, 2010 at 3:48 AM, Michael Snoyman mich...@snoyman.com wrote:
 On Sat, Nov 27, 2010 at 9:41 PM, Antoine Latter aslat...@gmail.com wrote:
 On Sat, Nov 27, 2010 at 10:59 AM, Jinjing Wang nfjinj...@gmail.com wrote:
 Dear list,

 From ghc 7.0.1 release notes:

 The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: 
 quoteType and quoteDec.

 Some of my code needs to be conditionally compiled to support both
 version 6 and 7, what is the recommended way to do it?

 ref:

 * 
 http://new-www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html

 Can you just not set those fields? Then the code should work as-is for
 both versions. You'll get warnings for GHC 7, I think.

 Sorry Jinjing, I didn't read your original email carefully enough.
 Antoine is absolutely correct, this is the better way to deal with
 defining a quasiquoter. My suggestion is only necessary if you want to
 *use* a quasiquoter.

 Michael




 --
 jinjing




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


Re: [Haskell-cafe] Conditional compilation for different versions of GHC?

2010-11-27 Thread Jinjing Wang
Thanks for explaining, it's a nice trick.

On Sun, Nov 28, 2010 at 11:16 AM, Antoine Latter aslat...@gmail.com wrote:
 On Sat, Nov 27, 2010 at 8:38 PM, Jinjing Wang nfjinj...@gmail.com wrote:
 Hi Michael, you are absolutely correct, cabal did set the flags 
 automatically.

 To sum up, here's what needs to be done:

 * add `flag ghc7` as a field in cabal
 * add:

    if flag(ghc7)
        build-depends:   base                      = 4.3        5
        cpp-options:     -DGHC7
    else
        build-depends:   base                      = 4          4.3

   in library field in cabal

 * add `{-# LANGUAGE CPP #-}` in source file
 * add

    #if GHC7
    x

    #else
    y

    #endif


  Hi Antonine, I don't know how to not set those fields in the
 constructor.. as a QQ noob, I'm just hacking on some legacy code. This
 code doesn't compile in GHC7, so I have to do this trick.

 * https://github.com/nfjinjing/mps/blob/master/src/MPS/TH.hs


 Something like:

 myQuoter = QuasiQuoter {
  quoteExp = expQuoter,
  quotePat = patQuoter
  }

 Will work in either version, but it will leave the un-set fields set
 to `undefined`, so you'll get a compile error if you try to use them.

 I haven't tested this, but I've done it with other record types.

 Take care,
 Antoine




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


Re: [Haskell-cafe] install GHC 7.0.1 RC on OS X?

2010-11-02 Thread Jinjing Wang
you can:

mv /Library/Frameworks/GHC.framework /Library/Frameworks/GHC.framework.2

then install GHC 7

just toggle between those paths to switch version ...


On Tue, Nov 2, 2010 at 1:07 AM, Edward Amsden eca7...@cs.rit.edu wrote:
 I'd like to install the GHC 7.0.1 RC on my mac (Snow Leopard, x86_64),
 but I don't want it to run over my current GHC 6.12.2 install.

 If I use the .pkg installer, it doesn't allow me to select the
 destination, and I worry that it will overwrite my 6.12.2 install.

 If I try to build from source, that requires me to use my current GHC,
 which (as I understand) would build for 32 bit.

 What other options do I have, or am I misunderstanding something?
 --
 Edward Amsden
 Undergraduate
 Computer Science
 Rochester Institute of Technology
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




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


Re: [Haskell-cafe] Re: String vs ByteString

2010-08-17 Thread Jinjing Wang
 John Millikin wrote:

 The reason many Japanese and Chinese users reject UTF-8 isn't due to
 space constraints (UTF-8 and UTF-16 are roughly equal), it's because
 they reject Unicode itself.

 +1.

 This is the thing Unicode advocates don't want to admit. Until Unicode has
 code points for _all_ Chinese and Japanese characters, there will be active
 resistance to adoption.

 --
 Live well,
 ~wren

For mainland chinese websites:

Most that became popular during web 1.0 (5-10 years ago) are using
utf-8 incompatible format, e.g. gb2312.

for example:

* www.sina.com.cn
* www.sohu.com

They didn't switch to utf-8 probably just because they never have to.

However, many of the popular websites started during web 2.0 are adopting utf-8

for example:

* renren.com (chinese largest facebook clone)
* www.kaixin001.com (chinese second largest facebook clone)
* t.sina.com.cn (an example of twitter clone)

These websites adopted utf-8 because (I think) most web development
tools have already standardized on utf-8, and there's little reason
change it.

I'm not aware of any (at least common) chinese characters that can be
represented by gb2312 but not in unicode. Since the range of gb2312 is
a subset of the range of gbk, which is a subset of the range of
gb18030. And gb18030 is just another encoding of unicode.

ref:

* http://en.wikipedia.org/wiki/GB_18030

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


Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: jhc 0.7.4

2010-08-09 Thread Jinjing Wang
I think the default locale of the terminal app on snow leopard is utf-8.

I can also report that I have no problem compiling the tar version of
jhc 0.7.4 on snow leopard 10.6.4 using ghc 6.12.1, need to install the
editline package though.


On Sun, Jul 11, 2010 at 5:33 AM, John Meacham j...@repetae.net wrote:
 On Sat, Jul 10, 2010 at 04:01:53PM -0500, Antoine Latter wrote:
 * running DrIFT on src/E/TypeCheck.hs fails with an illegal
 bytesequence in hGetContents. I'm guessing that this is only an issue
 when building DrIFT with GHC 6.12+, and that the file contains bytes
 illegal in UTF8. I deleted everything funny looking in the file and
 then it went smooth

 Hi, are you compiling from the tarball or the darcs repository? the
 tarball shouldn't require DrIFT to be installed. I had not tested DrIFT
 with 6.12 but that file should be in UTF8. Hmm... on OSX, is the default
 locale a UTF8 one? does ghc 6.12 properly encode to/from utf8 on it by
 defualt? could you check, I don't have a mac handy.

 * The way you use sed doesn't work with the BSD sed that ships with my
 Mac Book. Installing GNU sed and using it works. Similarly, BSD find
 doesn't know about '-name', so make hl-clean results in sadness.

 Hmm.. yeah, this has been reported before, but I was unable to reproduce
 the problem. But I may have accidentally been using a GNU sed, my mac at
 the time was highly gnu-ized. Could you send me a version that works.

 * jhci works great, but jhc crashes when I try to compile something:
 
 jhc test1.hs
 jhc 0.7.4 (tokfekyuvi-27)
 Finding Dependencies...
 Using Ho Cache: '/Users/alatter/.jhc/cache'
 Main                    [test1.hs]
 Typechecking...
 [1 of 1] Main             (.)
 test1.hs:9   - Warning: defaulting:  t93 = Jhc.Basics.Integer
 Compiling...
 [1 of 1] Main             
 ..
 Collected Compilation...
 -- typeAnalyzeMethods
 -- BoxifyProgram
 -- Boxy WorkWrap
 -- LambdaLift
 E
 jhc: stdout: hPutChar: invalid argument (Illegal byte sequence)
 

 Again, this seems like the handle is in UTF8 mode and we're trying to
 output something non-UTF8.

 Hmm.. clearly something about the locale is wrong... It is outputing a
 unicode character there, but it shoudl translate adn display to utf8
 just fine. perhaps ghc is not actually opening utf8 handles on your
 platform...

 * cabal install has a --jhc flag, but it doesn't seem to work:
 
 cabal install byteorder --jhc
 Resolving dependencies...
 cabal: internal error: impossible
 
 I have jhc installed in a non-standard location (under ${HOME}/usr) so
 I may need to have some environment variables set up. This is wil
 Cabal 1.8.0.4 and cabal-install 0.8.2

 The cabal support for jhc never worked actually, it wasn't written by
 me. There really isn't any easy way to integrate cabal with jhc right
 now, and even if there was, all of hackage has ghc specific
 dependencies. No doubt the solution to this problem will be involved, I
 have conciously decided to not think about the issue until I have full
 haskell 2010 support down pat. That will be more useful for writing
 portable programs in the short run.


 Keep up the good work!

 I have an implementation for STRefs I threw together this afternoon
 for jhc if you're interested. I can't test it properly, though, with
 the compiler crash above.

 Try without the '-v' flag, it shouldn't try printing the non ascii
 character then. or modify src/Stats.hs and replacet all the C.char
 constants with ascii equivalants. If there is a good way to test whether
 the terminal supports non-ascii characters, that would be good to put a
 test in jhc for.

        John

 --
 John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




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


Re: [Haskell-cafe] proposal: HaBench, a Haskell Benchmark Suite

2010-06-25 Thread Jinjing Wang
poor man's benchmark :)

http://github.com/nfjinjing/bench-euler

multi core aware, use bench-euler +RTS -N2 where 2 means 2 cores, and
watch your cpu fries :)

On Fri, Jun 25, 2010 at 7:24 AM, Andy Georges
andy.geor...@elis.ugent.be wrote:
 Hi Simon et al,


 I've picked up the HaBench/nofib/nobench issue again, needing a decent set of 
 real applications to do some exploring of what people these days call 
 split-compilation. We have a framework that was able to explore GCC 
 optimisations [1] -- the downside there was the dependency of these 
 optimisations on each other, requiring them to be done in certain order -- 
 for a multi-objective search space, and extended this to exploring a JIT 
 compiler [2] for Java in our case -- which posed its own problems. Going one 
 step further, we'd like to  explore the tradeoffs that can be made when 
 compiling on different levels: source to bytecode (in some sense) and 
 bytecode to native. Given that LLVM is quicly becoming a state-of-the-art 
 framework and with the recent GHC support, we figured that Haskell would be 
 an excellent vehicle to conduct our exploration and research (and the fact 
 that some people at our lab have a soft spot for Haskell helps too). Which 
 brings me back to benchmarks.

 Are there any inputs available that allow the real part of the suite to run 
 for a sufficiently long time? We're going to use criterion in any case given 
 our own expertise with rigorous benchmarking [3,4], but since we've made a 
 case in the past against short running apps on managed runtime systems [5], 
 we'd love to have stuff that runs at least in the order of seconds, while 
 doing useful things. All pointers are much appreciated.

 Or if any of you out there have (recent) apps with inputs that are open 
 source ... let us know.

 -- Andy


 [1] COLE: Compiler Optimization Level Exploration, Kenneth Hoste and Lieven 
 Eeckhout, CGO 2008
 [2] Automated Just-In-Time Compiler Tuning, Kenneth Hoste, Andy Georges and 
 Lieven Eeckhout, CGO 2010
 [3] Statistically Rigorous Java Performance Evaluation, Andy Georges, Dries 
 Buytaert and Lieven Eeckhout, OOPSLA 2007
 [4] Java Performance Evaluation through Rigorous Replay Compilation, Andy 
 Georges, Lieven Eeckhout and Dries Buytaert, OOPSLA 2008
 [5] How Java Programs Interact with Virtual Machines at the 
 Microarchitectural Level, Lieven Eeckhout, Andy Georges, Koen De Bosschere, 
 OOPSLA 2003


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




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


[Haskell-cafe] yet another functional reactive programming tutorial :)

2010-05-26 Thread Jinjing Wang
Dear list,

As I'm learning frp and reading the wonderful tutorial at

http://www.formicite.com/dopage.php?frp/frp.html

, I'm putting up some more basic cheatsheet style tutorial for myself.

http://github.com/nfjinjing/frp-guide

Feel free to take advantage of it.

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


Re: [Haskell-cafe] About code style ?

2010-02-02 Thread Jinjing Wang
fac n = let {
  f = foldr (*) 1 [1..n]
  } in f

:D

sorry for double reply, need to cc cafe, this is fun.

On Tue, Feb 2, 2010 at 4:33 PM, zaxis z_a...@163.com wrote:

 thanks for all suggestions.


 zaxis wrote:

 For me i like C style instead of layout. For example,
 func1 a = do
      -- ...
      a * 2
      -- ...

 I always write it as:
 func1 a = do {
   -- ...;
    a * 2;
   -- ...;
 }

 However, i donot know how to write pure function using C style.
 func1 a = {
   -- ...;
    a * 2;
   -- ...;
 }

 will not compile without `do`.

 Sincerely!



 -
 fac n = foldr (*) 1 [1..n]
 --
 View this message in context: 
 http://old.nabble.com/About-code-style---tp27414627p27416932.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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




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


Re: [Haskell-cafe] Web application interface

2010-01-13 Thread Jinjing Wang
The hyena backend is essentially just a translator between hack and
wai, i failed to finished it since I can't understand iteratee
(seriously) and eventually got distracted  ...

What hyena tries to solve can't be realized in hack, so there's not
too much reason for a backend anyway.

Hyena is especially tuned for streaming and that's exactly what hack
can't do (in practice).

http://github.com/nfjinjing/hack-handler-hyena


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


Re: [Haskell-cafe] GHC 6.12 on OS X 10.5

2009-12-21 Thread Jinjing Wang
not sure if this helps, but try:

# ports share lib export
export CPATH=~/local/include
export LIBRARY_PATH=~/local/lib
export LD_LIBRARY_PATH=~/local/lib
export DYLD_LIBRARY_PATH=~/local/lib

replace ~/local/ with your ports path

On Tue, Dec 22, 2009 at 5:43 AM, Tom Tobin korp...@korpios.com wrote:
 On Mon, Dec 21, 2009 at 1:38 PM, Tom Tobin korp...@korpios.com wrote:
 On Mon, Dec 21, 2009 at 4:32 AM, Conor McBride
 co...@strictlypositive.org wrote:
 I thought I'd record my upgrade exerience (so far) in case anyone else
 finds it useful, and (more selfishly) in case anyone has some helpful
 advice. Summary of situation

 You just described what I went through last night with GHC 6.12 before
 giving up and going to bed, except that I'm on Snow Leopard (OS X
 10.6).  I got the undefined symbols errors when trying to compile
 cpphs, which came up at some point in the build process when trying to
 install Happstack via cabal 0.8.0.  I was wondering if if something
 was getting confused between my MacPorts libraries and OS X, and your
 experience certainly makes it seem that way; I have the MacPorts paths
 set up in my .cabal/config file as extra-include-dirs and
 extra-lib-dirs, otherwise I can't get particular libraries (e.g.,
 pcre-lite) to compile.

 I'm going to wipe my .cabal and .ghc and try from scratch to build as
 much as possible without the MacPorts paths, only re-adding them for
 single builds as necessary; I'll write back after I see how that goes.

 This time, after wiping .ghc and .cabal, I immediately did cabal
 update followed by cabal install happstack (without going and
 changing the extra-include-* settings in .cabal/config to point at the
 MacPorts dirs).  cpphs compiled fine this time, but I got a failure
 due to haskell-src-exts not building; haskell-src-exts in turn
 complained that happy wasn't installed.  I went and installed happy,
 then haskell-src-exts (which installed v1.3.4), and then did cabal
 install happstack again which installed haskell-src-exts v1.0.1 (I
 guess GHC understands how to deal with two different installed library
 versions?).

 This time the install died on HJScript:

 **
 [ 2 of 26] Compiling HJScript.Monad   ( src/HJScript/Monad.hs,
 dist/build/HJScript/Monad.o )

 src/HJScript/Monad.hs:51:10:
    A pattern match on a GADT requires -XGADTs
    In the pattern: EmptyBlock
    In the definition of `mappend': mappend EmptyBlock b = b
    In the instance declaration for `Monoid (Block ())'
 cabal: Error: some packages failed to install:
 HJScript-0.4.5 failed during the building phase. The exception was:
 ExitFailure 1
 **

 I have no idea what to do next, so I'll probably bring this particular
 issue up on the Happstack list next.

 My questions at this point:

 1) The original problem definitely looks like it's related to library
 confusion between the system libs and the MacPorts libs.  Is there any
 way of sanely handling this when I need a library that's available
 through MacPorts but not OS X's system libs?  (MacPorts' insistence on
 maintaining an entirely separate library stack from the OS X system
 libraries is starting to make me crazy.  ::sigh::)

 2) Regarding haskell-src-exts: why wasn't happy wasn't pulled into the
 dependency graph in the first place?
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




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


[Haskell-cafe] ANN: moe html combinator

2009-08-27 Thread Jinjing Wang
hand written html is fine, except for the closing tags:

what if

  html' - do
head' - do
  meta
[http_equiv Content-Type, content text/html; charset-utf-8] (/)
  title' - str my title
  link [rel icon, _type image/png, href panda_icon.png] (/)

body' - do
  div [_class container] - do
str hello world

produces

html
  head
meta http-equiv=Content-Type content=text/html; charset-utf-8
/meta
title
  my title
/title
link rel=icon type=image/png href=panda_icon.png
/link
  /head
  body
div class=container
  hello world
/div
  /body
/html

That's moe. There's also extra dsl sugar / flavors for your
convienence, including (currently available) markdown and kawaii.

It's a new library, tries to bring some haskell fun back to web
programming, so .. enjoy.

- moe: http://hackage.haskell.org/package/moe

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


Re: [Haskell-cafe] ANN: yst 0.2.1

2009-08-03 Thread Jinjing Wang
It's possible to serve the generated site with maid, in case apache is
not available:

cabal update
cabal install maid

yst create testsite
cd testsite
yst

cd site
maid

now goto http://localhost:3000/

On Mon, Aug 3, 2009 at 9:05 AM, John MacFarlanej...@berkeley.edu wrote:
 I'm pleased to announce the release of yst, now available on HackageDB.
 yst generates static websites from YAML or CSV data files and
 StringTemplates. This approach combines the speed, security, and ease of
 deployment of a static website with the flexibility and maintainability
 of a dynamic site that separates presentation and data.

 The easiest way to get a feel for yst is to try it:

 cabal update
 cabal install yst
 yst create testsite
 cd testsite
 yst

 yst attempts to fill a niche between two kinds of site creation tools.
 On the one hand you have simple static site generators like webgen,
 webby, nanoc, and my old custom system using make and pandoc. On the
 other hand, you have dynamic web frameworks like rails and django.
 For my own smallish websites, I found that the dynamic frameworks were
 overkill. Nobody but me was going to edit the pages, and I didn't
 want the trouble of writing and deploying a dynamic site, setting up
 a web server, and administering a database. A static site would be
 faster, easier to deploy, and more secure. But the dynamic frameworks
 offered one thing that the static site generators did not: an easy way
 to separate data from presentation. This was becoming increasingly
 important to me as I found myself constantly updating the same
 information (say, publication data for a paper) in multiple places (say,
 a LaTeX CV and a differently formatted web listing of papers).

 What I wanted was a site generation tool that used YAML text files
 as a database and allowed different kinds of documents to be produced
 from the same data.  I couldn't find anything that did just what I
 wanted, so I wrote yst. By way of illustration, here are the build
 instructions for HTML and LaTeX versions of a CV, plus a web page with a
 list of papers:

 - url: cv.html
  title: CV
  template: cv.st
  data_common:  cvdata
    contact: from contact.yaml
    jobsbyemployer: from jobs.yaml order by start group by employer
    degrees: from degrees.yaml order by year desc
    awards: from awards.yaml order by year desc group by title
    papers: from papers.yaml order by year desc where (not (type = 'review'))
    reviews: from papers.yaml order by year desc where type = 'review'
    talks: from talks.yaml where date  '2009-09-01' order by date desc group 
 by title
    dissertations: from dissertations.yaml order by role then year group by 
 role
    theses: from theses.yaml order by year then student
    courses: from courses.yaml order by number group by title
  data:
    :  *cvdata
    html: yes

 - url: cv.tex
  title: CV
  inmenu: no
  template: cv.st
  layout: layout.tex.st
  data:
    :  *cvdata
    html: yes

 - url: papers.html
  title: Papers
  template: papers.st
  data:
    papersbyyear:  from papers.yaml order by year desc then title group by year

 yst's query language is limited, and there are lots of things you can
 do with a full-fledged database that you can't do with yst. But yst
 is ideal, I think, for small to medium data-driven sites that are
 maintained by a single person who likes working with plain text. It
 scratched my itch, anyway, and I release it in case anyone else has the
 same itch.

 Code, documentation, and bug reports:  http://github.com/jgm/yst/tree/master

 John

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




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


[Haskell-cafe] Help needed to pick a better name then hack

2009-07-03 Thread Jinjing Wang
Hack is such an inconvenient name for a package, may I get some
inspiration from renaming it?

Also, is there an idiom to use when upgrading package name on hackage?

Best,

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


[Haskell-cafe] ANN: loli: a minimal web dev DSL

2009-06-29 Thread Jinjing Wang
loli is a DSL built on hack. It allows you to easily define routes,
build your custom template backends through a simple Template
interface, and integrate with other hack middleware.

* driver

The simplest app looks like this

import Network.Loli
import Hack.Handler.Happstack

main = run . loli $ get / (text loli power)

* route

get /hello $ do
  text hello

will route /hello to a controller that outputs hello.

* middleware

using a middleware is just as declaring

middleware lambda

* template

the template interface is

class Template a where
  interpolate :: a - String - Context - IO String

Context is just [(String, String)]

After implementing your own template engine, you can use

output $ your-engine-constructor template-name

* demo

I put the source of a dummy paste app on itself:

http://lolipaste.easymic.com/0-lolipaste.haskell


loli is on hackage, lolipaste is in loli repo on github:

* http://github.com/nfjinjing/loli

happy hacking

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


[Haskell-cafe] [ANN] Nemesis : easy task management

2009-06-12 Thread Jinjing Wang
You can have a description file named Nemesis, with content

nemesis = do

  clean
[ **/*.hi
, **/*.o
, manifest
]

  task dist $ do
sh cabal clean
sh cabal configure
sh cabal sdist

  task i (sh ghci -isrc src/System/Nemesis.hs)

  task manifest $ do
sh find . | grep 'hs$'  manifest


then after run `nemesis`, there will be a compiled bin `nem` in your
local path, which allows you to do

`nem clean`

Install with `cabal install nemesis`

Cheers,


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


Re: [Haskell-cafe] ANN: Cute Hack - Hyena handler + Bamboo Blog Engine :)

2009-04-25 Thread Jinjing Wang
Yes, the spec is almost a direct translation from Rack.

For middleware, I translated some from Rack, but it does not have to
be a port. I'm just lazy.

Rack borrowed some basic middleware from WSGI too, like Lint.

About the style, it's a bit weird, yes. But only in module scope ;)

On Sat, Apr 25, 2009 at 7:00 PM, Sebastiaan Visser sfvis...@cs.uu.nl wrote:
 What kind of port is this? Direct translation from ruby source?

 I see that you are using the (.) for OO-style reversed function application.
 Which feels a bit weird at first sight.

 Snippet from your Hack.Handler.Kibro:

handle app = do
  env - get_env
  response - app env .liftIO

  -- set response
  response.headers.mapM_ (splash setHeader)
  response.status.show.setHeader Status
  response.body.output

 On Apr 25, 2009, at 7:58 AM, Jinjing Wang wrote:

 Hia,

 A few interesting progress on Hack:

 * many middleware ported from Rack, including a lambda! ( just like a
 pony for wsgi, and a lobster for rack )
 * 2 handlers, one for Kibro on fcgi / lighttpd, one for Hyena web server
 * apps are portable, Bamboo is a port of Panda that runs on Hack,
 works fine with both handlers
 * Hyena handler is still experimental

 A lambda app looks like this

 -- Main.hs source

 module Main where

 import Hack
 import Hack.Utils

 import Hack.Handler.Hyena
 import Hack.Contrib.Lambda

 main = run $ lambda dummy_app

 -- compile

 ghc --make -O2 Main.hs

 -- run
 ./Main


 now go to http://localhost:3000/lambda

 Cheers,

 Links:

 * [Hack] (http://github.com/nfjinjing/hack/tree/master)
 * [Bamboo] (http://github.com/nfjinjing/bamboo/tree/master)





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


[Haskell-cafe] ANN: Cute Hack - Hyena handler + Bamboo Blog Engine :)

2009-04-24 Thread Jinjing Wang
Hia,

A few interesting progress on Hack:

* many middleware ported from Rack, including a lambda! ( just like a
pony for wsgi, and a lobster for rack )
* 2 handlers, one for Kibro on fcgi / lighttpd, one for Hyena web server
* apps are portable, Bamboo is a port of Panda that runs on Hack,
works fine with both handlers
* Hyena handler is still experimental

A lambda app looks like this

-- Main.hs source

module Main where

import Hack
import Hack.Utils

import Hack.Handler.Hyena
import Hack.Contrib.Lambda

main = run $ lambda dummy_app

-- compile

ghc --make -O2 Main.hs

-- run
./Main


now go to http://localhost:3000/lambda

Cheers,

Links:

* [Hack] (http://github.com/nfjinjing/hack/tree/master)
* [Bamboo] (http://github.com/nfjinjing/bamboo/tree/master)

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


[Haskell-cafe] [ANN] Hack: a sexy Haskell Webserver Interface ^^

2009-04-20 Thread Jinjing Wang
Simplest app should look like this

module Main where

import Hack
import Hack.Handler.Kibro

hello :: Application
hello = \env - return $ Response
{ status  = 200
, headers = [ (Content-Type, text/plain) ]
, body= Hello World
}

main = run hello

Hack is a brainless port of the brilliant Ruby Rack framework. Rack is
very modular and that's
very important.

Rack utilities and middlewares should be able to be ported with
minimal effort, I hope.

link / source: http://github.com/nfjinjing/hack/tree/master

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


[Haskell-cafe] message passing style in Monad

2008-09-10 Thread jinjing
I found that as I can do

  xs.map(+1).sort

by redefine . to be

  a . f = f a
  infixl 9 .

I can also do

  readFile readme.markdown . lines . length

by making

  a . b = a .liftM b
  infixl 9 .

Kinda annoying, but the option is there.

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


[Haskell-cafe] Re: message passing style in Monad

2008-09-10 Thread jinjing
sorry about the confusion, too much drinks.
I used the redefined . in the difination of .. it should really just be

  flip liftM

On Wed, Sep 10, 2008 at 9:14 PM, jinjing [EMAIL PROTECTED] wrote:
 I found that as I can do

  xs.map(+1).sort

 by redefine . to be

  a . f = f a
  infixl 9 .

 I can also do

  readFile readme.markdown . lines . length

 by making

  a . b = a .liftM b
  infixl 9 .

 Kinda annoying, but the option is there.

 - jinjing

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


Re: [Haskell-cafe] experimental static blog engine in Haskell (file based, markdown syntax)

2008-09-08 Thread jinjing
It's up ( I think, since it's my first cabal ).

cabal install panda

kibro new ttmyblog
cd myblog

rm -r db; rm -r public
git clone git://github.com/nfjinjing/panda-template.git db
sh db/scripts/bootstrap.sh

kibro start



On Sun, Sep 7, 2008 at 4:26 AM, Don Stewart [EMAIL PROTECTED] wrote:
 nfjinjing:
 Hia,

 It's called Panda. It's pretty young, no theme, no tags, no comments,
 around 360 lines of code and uses Kibro to bootstrap.

 hosted on GitHub:
 http://github.com/nfjinjing/panda/

 a quick demo at:
 http://jinjing.blog.easymic.com/

 Awesome! Kibro seems to be taking off.

 Will you release it on hackage.haskell.org?

 -- Don

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


[Haskell-cafe] experimental static blog engine in Haskell (file based, markdown syntax)

2008-09-06 Thread jinjing
Hia,

It's called Panda. It's pretty young, no theme, no tags, no comments,
around 360 lines of code and uses Kibro to bootstrap.

hosted on GitHub:
http://github.com/nfjinjing/panda/

a quick demo at:
http://jinjing.blog.easymic.com/

cheers,

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


Re: [Haskell-cafe] ANN: Haskore tutorial (programming music using Haskell)

2008-08-07 Thread jinjing
Thanks Henk-Jan van Tuyl,

It's been updated/changed accordingly.

jinjing

On Fri, Aug 8, 2008 at 1:42 AM, Henk-Jan van Tuyl [EMAIL PROTECTED] wrote:
 On Tue, 05 Aug 2008 10:59:10 +0200, jinjing [EMAIL PROTECTED] wrote:

 Hi there,

 Here's the project link:

 http://github.com/nfjinjing/haskore-guide/tree/master/doc/index.markdown

 I found Haskore pretty fun :) so I'm documenting it while learning it.
 Please don't hesitate to give suggestions / corrections.



 About the installation section: I think beginners will be grateful if you
 write down the full darcs get commands and explain the --global parameter
 of the cabal install command.

 There are two more packages that need to be downloaded:
  - package hosc depends on package binary
  - package haskore depends on package unix

 Windows users will be grateful if you tell them that Haskore cannot be built
 on Windows, because of the dependance on the unix package. It would have
 saved me a lot of time if I knew that beforehand.



 For the people interested in porting Haskore to Windows I'll describe what I
 have done so far:

 src\Haskore\Basic\Timer\Posix.hs:
 System.Posix.Unistd.usleep replaced by Control.Concurrent.threadDelay
 (of course, the name of the file is not correct after this; better put the
 timer function in another file)


 File Haskore.cabal:
 removed unix from section Build-depends

 Added to cabal file:
   if os(windows)
cpp-options: -DWIN32

 Added to src\Haskore\Interface\CSound\Play.lhs:

 {-# OPTIONS -cpp #-}

 and around the signal handling part and the line

 import qualified System.Posix.Signals as Signals

 :

 #ifndef WIN32
 ...
 #endif


 Same treatment for src/Haskore/Interface/MIDI/Play.lhs

 Finally I discovered that in the file
  src/Haskore/Interface/SuperCollider/Channel/Env.hs
 environment variables are set and that there is no setEnv or putEnv for
 Windows.
 GCC knows the function setenv(), but that function does not work as expected
 (on Windows); once the program terminates, the created environment variable
 has dissapeared. After I discovered that, I decided it would be too much yak
 shaving for me to go on. To solve this problem, on would either create an
 improved setenv() function, or redesign Haskore to pass the information some
 other way (and of course the program(s) that read this information).


 --
 Met vriendelijke groet,
 Henk-Jan van Tuyl


 --
 http://functor.bamikanarie.com
 http://Van.Tuyl.eu/
 --


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


[Haskell-cafe] ANN: Haskore tutorial (programming music using Haskell)

2008-08-05 Thread jinjing
Hi there,

Here's the project link:

http://github.com/nfjinjing/haskore-guide/tree/master/doc/index.markdown

I found Haskore pretty fun :) so I'm documenting it while learning it.
Please don't hesitate to give suggestions / corrections.

Questions:

* How much music theory should be there ? ( I'm gonna learn those anyway )
* What kind of examples would be cool ?

regards,

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


[Haskell-cafe] parallel_map_reduce, in easy one liner mod

2008-07-03 Thread jinjing
Hi haskellers,

So.. the type says it all

p_map_reduce :: ([a] - b) - (b - b - b) - [a] - b


so the idea is to write your computation extensive funciton as
a map_reduce function, simplest example: sum ( can be seen as
map id then reduce (+) )

then instead of calling:

sum xs

just call:

p_map_reduce sum (+) xs


the function in the background will split the xs into 16 parts,
and use all your cores to process the computation. Enless the
computation from the map_reduce function is too trivial or the list is
too small,
it should bump all your cores to 100% usage, and linearly increase
overall performance.

You can customize the number of parts by calling the helper function
p_map_reduce_to

I hope this can be useful to someone besides me :)

here is the code
warning: i'm using a very annoying coding style, by redefining the (.)
operater to be reverse application. Please forgive me and metally transform
the order, or just pretend you are reading Java / Python / Ruby or whatever  :)


module Main where

import Data.List
import Control.Parallel
import Prelude hiding ((.))

-- for my poor oo mind
(.) :: a - (a - b) - b
a . f = f a

infixl 9 .

(...) :: (b - c) - (a - b) - a - c
(...) f g x = f (g x)


-- helpers
reduce = foldl1
in_group_of n []   = []
in_group_of n xs   = xs.take(n) : xs.drop(n).in_group_of(n)
split_ton xs   = xs.in_group_of(size)
  where size = if xs.length  n then n else xs.length `div` n


-- parallel processing
p_eval' xs   = xs.pseq(xs.reduce(par))
p_reduce' op xs  = xs.p_eval'.reduce(op)

p_map_reduce_to n m r xs = xs.split_to(n).map(m).p_reduce'(r)
p_map_reduce m r xs  = p_map_reduce_to 16 m r xs


-- test
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)

fibs xs   = xs.map(fib).sum
test_list = replicate 50 30
s_fibs= test_list.fibs
p_fibs= test_list.p_map_reduce fibs (+)

main = p_fibs.show.putStrLn
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] message passing style like in Haskell?

2008-06-21 Thread jinjing
After some fiddling with this style, here is what I came up with
for the 8 queens problem in the 99 problem set. It's quite entertaining ...
( note: it's brute force and requires a combination library )

queens2 n = n.permutations.filter all_satisfied where
  all_satisfied queens = queens.diff_col  queens.diff_diag
  diff_col queens = queens.unique.is queens
  diff_diag queens =
n .combinations 2
  .map (map (subtract 1))
  .map (id  flip cherry_pick queens)
  .any same_dist.not where
same_dist (row_pair, col_pair) =
  row_pair.foldl1 (-).abs == col_pair.foldl1 (-).abs

  -- generic helper
  cherry_pick ids xs = ids.map (xs !!)
  is a b = a == b
  unique xs = nub xs

Guess this can conclude this experiment :)

jinjing

On Sun, Jun 22, 2008 at 1:10 AM, Ian Lynagh [EMAIL PROTECTED] wrote:
 On Fri, Jun 20, 2008 at 07:57:58AM +0200, Ketil Malde wrote:
 Albert Y. C. Lai [EMAIL PROTECTED] writes:

  While we are kind of on this topic, what makes the characters ħ þ
  prefix operator by default, while º and most other odd ones infix?

  alphanumeric vs non-alphanumeric

 Testing this, I find that isAlpha is True also for 'º', but as the OP
 claims, Haskell will use it as a(n infix) symbol.

 This is a bug in GHC. The characters = '\255' were done specially, but
 incorrectly for many of those = '\128'. I'll fix it, probably by just
 removing the specialisation for them.


 Thanks
 Ian

 ___
 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] message passing style like in Haskell?

2008-06-18 Thread jinjing
Hi guys,

This is my second attempt to learn Haskell :)

Any way here's the code:

module Dot where
import Prelude hiding ( (.) )

(.) :: a - (a - b) - b
a . f = f a

infixl 9 .


So for example, 99 questions: Problem 10
(*) Run-length encoding of a list.



comparing:

encode xs = map (\x - (length x,head x)) (group xs)

to

encode xs = xs.group.map token where token x = (x.length, x.head)




I found starting with data and working my way to a solution seems to be
easier to think with, or maybe it's just me ...

What is your thought?

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