[Haskell-cafe] How to use Template Haskell based on code that generated by another Template?

2013-07-03 Thread Magicloud Magiclouds
I have a yesod project, which generated, say, UserPassword in module Model.
Then I wrote my template code which generate a piece of code to use
UserPassword. I imported Model in my code.

Then I got
Illegal variable name: `UserPassword'
When splicing a TH declaration:
-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghci ghc - JS (Emscripten)

2013-07-03 Thread B B
Emscripten is meant to translate ANY LLVM IR code to javascript and it
should work (as I belive).
I've tried to compile 'hello wrold' Haskell program to JS using Emscripten
but I faced a problem, that in generated LLVM IR code there is no C-like
main function (https://github.com/kripken/emscripten/issues/500) so there
has to be a runtime library that has to be linked and will run the code -
is this RTS or something else?
If its RTS I understeand I should compile it to javascript and then provide
it as a library to emscripten? Do you have a working RTS js version?

I want to simply try emscripten and see how it performs on such GHC
generater LLVM IRs.


2013/7/2 Luite Stegeman stege...@gmail.com

 On Tue, Jul 2, 2013 at 4:38 PM, B B blackbox.dev...@gmail.com wrote:

 Thank you for all the replies.
 Luite Stegeman - I was thinking that the LLVM IR code is optimized
 already or you can run LLVM IR optimization passes to get rid of such
 things. I think compiling with ghc -fllvm generates LLVM bitcode and then
 you can simply run emscripten on it to get Javascript - and it should work
 as expected.


 Most of the optimizations that GHC does are on Core, so you also get those
 if you use Core or STG as the source. You do miss out on the later
 optimization passes (GHC optimizes Cmm with Hoopl, and LLVM optimizes
 again). We implement this in GHCJS ourselves, optimizing the generated
 JavaScript.

 Since GHC itself is written in Haskell, it would be a good goal to compile
 simple Haskell programs first and make sure that the RTS is working (you'll
 need to compile the Cmm and C RTS files to LLVM). You can try to get the
 GHC Testsuite [1] running. The GHCJS testsuite [2] might also be useful, it
 contains much of the GHC Testsuite and a runner program that checks the
 JavaScript results against native Haskell.

 Like i said in the previous post, the generated code is a bit weird:
 stacks are allocated dynamically, functions never return, there are only
 tail calls. Emscripten might have a hard time with this.

 [1] https://github.com/ghc/testsuite
 [2] https://github.com/ghcjs/ghcjs/tree/master/test

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


Re: [Haskell-cafe] ghci ghc - JS (Emscripten)

2013-07-03 Thread Luite Stegeman
On Wed, Jul 3, 2013 at 11:06 AM, B B blackbox.dev...@gmail.com wrote:

 Emscripten is meant to translate ANY LLVM IR code to javascript and it
 should work (as I belive).


It cannot compile ANY LLVM code: It's heavily geared towards porting C and
C++ code to JavaScript, and still there are some limitatons, see:

https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations

Also the FAQ mentions how event loops should be converted to something that
emscripten can deal with:

https://github.com/kripken/emscripten/wiki/FAQ

Since the GHC runtime never returns, you'd probably have to do something
similar.

I've tried to compile 'hello wrold' Haskell program to JS using Emscripten
 but I faced a problem, that in generated LLVM IR code there is no C-like
 main function (https://github.com/kripken/emscripten/issues/500) so there
 has to be a runtime library that has to be linked and will run the code -
 is this RTS or something else?
 If its RTS I understeand I should compile it to javascript and then
 provide it as a library to emscripten? Do you have a working RTS js version?


I don't have a working version. The files you need are probably mostly in
the rts directory of the GHC repository:
https://github.com/ghc/ghc/tree/master/rts , but you might need a bit more,
like libffi and gmp (unless you use integer-simple).


 I want to simply try emscripten and see how it performs on such GHC
 generater LLVM IRs.


I don't think it's that easy... I'd expect a few weeks of work minimum to
get very simple examples like Hello, world working. And a few months for
something big like GHC.

Also keep in mind that the code will probably be pretty big, GHC (and GHCi,
which is the same file) is ~65MB on my linux system, so getting well over
100MB of JavaScript wouldn't be terribly surprising.

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


[Haskell-cafe] Liber Amicorum for Doaitse Swierstra.

2013-07-03 Thread Jurriaan Hage
Dear all,

Prof. Doaitse Swierstra is retiring on August 1 of this year, and is
leaving the very functional programming minded Software Technology
group that he has led for many decades.

We have compiled a Liber Amicorum in his honour that we handed
to him after his farewell speech on May 30th. You can find a download
of this book at:

http://www.cs.uu.nl/people/jur/liberdoaitseswierstra.pdf

Not all contributions are ``technical'', and not all of them are in English, but
counting up the pages, I guess about 75 percent is.

best,
Jurriaan Hage



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


Re: [Haskell-cafe] ghci ghc - JS (Emscripten)

2013-07-03 Thread B B
Thank you for your response :)
Could you please answer one additional question - why you, while creating
GHCJS didn't base on emscripten? Why haven't you patched it and created
custom solution?
Is GHCJS production ready? Also - Can I use GHCJS to compile big projects
(like GHC or GHCI) to Javascript?

When you mentioned the file sizes I thought it would be good to further
introduce what we are trying to do.
We want to be able to send a haskell code to a server to compile it and
return the resulted JS to user as a compiled library. We want users to be
able to connect these compiled functions together to get some interactive
results.
for example: user is creating 2 functions (pseudocode): a(x) and b(x). They
are send to server and compiled to JS. Then in an online tool user is
connecting (visually with lines) a data (lets say a list of ints) [] - a
- b. While connecting it we want this tool to interpret such connections
and visualise the data on each step - so we want to have some kind of
runtime or interpreter on client side.



2013/7/3 Luite Stegeman stege...@gmail.com

 On Wed, Jul 3, 2013 at 11:06 AM, B B blackbox.dev...@gmail.com wrote:

 Emscripten is meant to translate ANY LLVM IR code to javascript and it
 should work (as I belive).


 It cannot compile ANY LLVM code: It's heavily geared towards porting C and
 C++ code to JavaScript, and still there are some limitatons, see:

 https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations

 Also the FAQ mentions how event loops should be converted to something
 that emscripten can deal with:

 https://github.com/kripken/emscripten/wiki/FAQ

 Since the GHC runtime never returns, you'd probably have to do something
 similar.

 I've tried to compile 'hello wrold' Haskell program to JS using Emscripten
 but I faced a problem, that in generated LLVM IR code there is no C-like
 main function (https://github.com/kripken/emscripten/issues/500) so
 there has to be a runtime library that has to be linked and will run the
 code - is this RTS or something else?
 If its RTS I understeand I should compile it to javascript and then
 provide it as a library to emscripten? Do you have a working RTS js version?


 I don't have a working version. The files you need are probably mostly in
 the rts directory of the GHC repository:
 https://github.com/ghc/ghc/tree/master/rts , but you might need a bit
 more, like libffi and gmp (unless you use integer-simple).


 I want to simply try emscripten and see how it performs on such GHC
 generater LLVM IRs.


 I don't think it's that easy... I'd expect a few weeks of work minimum to
 get very simple examples like Hello, world working. And a few months for
 something big like GHC.

 Also keep in mind that the code will probably be pretty big, GHC (and
 GHCi, which is the same file) is ~65MB on my linux system, so getting well
 over 100MB of JavaScript wouldn't be terribly surprising.

  luite

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


[Haskell-cafe] Catch multiple exceptions using 'Control.Exception'

2013-07-03 Thread Nikita Karetnikov
I'm trying to update a package that uses 'Control.OldException' (works
with GHC 6.10.4).  Here is a relevant (and simplified) part:

import Control.OldException

-- | A predicate matching synchronous exceptions.
syncExceptions :: Exception - Maybe Exception
syncExceptions (AsyncException _) = Nothing
syncExceptions e  = Just e

throwAsync :: IO a
throwAsync = throwIO $ AsyncException StackOverflow

throwArith :: IO a
throwArith = throwIO $ ArithException DivideByZero

'syncExceptions' is usually used like this:

*Main tryJust syncExceptions throwArith
Left divide by zero
*Main tryJust syncExceptions throwAsync  -- pass through
*** Exception: stack overflow

The above doesn't work with GHC 7.6.3 because 'Control.OldException' [1]
was removed.  And 'Control.Exception' doesn't have the 'Exception' type.

Is there a way to adapt 'syncExceptions' to work with
'Control.Exception'?

[1] 
http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/Control-OldException.html


pgpxks_kAP6YQ.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghci ghc - JS (Emscripten)

2013-07-03 Thread Luite Stegeman
On Wed, Jul 3, 2013 at 12:26 PM, B B blackbox.dev...@gmail.com wrote:

 Thank you for your response :)
 Could you please answer one additional question - why you, while creating
 GHCJS didn't base on emscripten? Why haven't you patched it and created
 custom solution?


I didn't know a good way to get the tail calling to work, and also it
looked like it would be hard to make it as convenient to use as higher
level JavaScript (we can just wrap JS objects in Haskell thunks, insert
foreign imports directly in the functions (example: [1] ).

That said, asm.js/emscripten have progressed a lot since I started working
on this (I started on the 'gen2' code generator in August last year).
Perhaps when JS gets native tail calls, it might be time to give
LLVM/emscripten another look.


 Is GHCJS production ready? Also - Can I use GHCJS to compile big
 projects (like GHC or GHCI) to Javascript?


I think GHCJS should be able to compile all Haskell code in GHC, but we
haven't tested this yet. The tricky bit is probably getting foreign code
work, and creating a working installation that includes all other things,
like libraries and a package database. Usually, GHCi loads object files for
the libraries when running Haskell code. Obviously you can't run machine
code with JavaScript, so you'd have to find a way around it. GHCJS includes
an IO layer, which can be used to set up a virtual filesystem [2], but the
API is far from finished.


 When you mentioned the file sizes I thought it would be good to further
 introduce what we are trying to do.
 We want to be able to send a haskell code to a server to compile it and
 return the resulted JS to user as a compiled library. We want users to be
 able to connect these compiled functions together to get some interactive
 results.


Ah it's much easier if the code can be compiled on the server. This is more
or less what Daniil Frumin is doing for his Google Summer of Code project
[3]. We are using GHC on the server for non-interactive things, and GHCJS
to compile interactive code that is run on the client. Our main goal is to
get interactive graphics with the diagrams [4] library working.

Currently he is working on building a good sandbox for the compiler on the
server (With SELinux, rlimits and cgroups) so that we can compile code, and
run Template Haskell safely. I'm working on improving the GHCJS linker, so
that we can support incremental code loading more easily (so users can
download just the code for the new function they wrote, instead of the
whole program every time)


 for example: user is creating 2 functions (pseudocode): a(x) and b(x).
 They are send to server and compiled to JS. Then in an online tool user is
 connecting (visually with lines) a data (lets say a list of ints) [] - a
 - b. While connecting it we want this tool to interpret such connections
 and visualise the data on each step - so we want to have some kind of
 runtime or interpreter on client side.


I have a very crude example of this type here:

http://hdiff.luite.com/reduce/

It's hacked together in one day, replacing the GHCJS main loop with one
that draws a graph of the stack and heap every reduction step. It could be
much better obviously, with better forward backward stepping/tracing and
more information about the objects, and of course improved presentation.

When we have the SELinux sandbox working, I plan to work on this again, so
that users can enter/compile their own code.

luite

[1] Foreign import javascript example:
https://github.com/ghcjs/ghcjs-jquery/blob/03b71effaeb059c9847306c93d69839588354134/JavaScript/JQuery/Internal.hs#L119
[2] GHCJS IO Layer: https://github.com/ghcjs/shims/blob/master/src/io.js
[3] Daniil Frumin's GSoC project:
https://github.com/co-dan/interactive-diagrams
[4] Diagrams library: http://projects.haskell.org/diagrams/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Catch multiple exceptions using 'Control.Exception'

2013-07-03 Thread Erik Hesselink
Perhaps you can use `catches` [0]?

Erik

[0] 
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception.html#v:catches

On Wed, Jul 3, 2013 at 12:47 PM, Nikita Karetnikov
nik...@karetnikov.org wrote:
 I'm trying to update a package that uses 'Control.OldException' (works
 with GHC 6.10.4).  Here is a relevant (and simplified) part:

 import Control.OldException

 -- | A predicate matching synchronous exceptions.
 syncExceptions :: Exception - Maybe Exception
 syncExceptions (AsyncException _) = Nothing
 syncExceptions e  = Just e

 throwAsync :: IO a
 throwAsync = throwIO $ AsyncException StackOverflow

 throwArith :: IO a
 throwArith = throwIO $ ArithException DivideByZero

 'syncExceptions' is usually used like this:

 *Main tryJust syncExceptions throwArith
 Left divide by zero
 *Main tryJust syncExceptions throwAsync  -- pass through
 *** Exception: stack overflow

 The above doesn't work with GHC 7.6.3 because 'Control.OldException' [1]
 was removed.  And 'Control.Exception' doesn't have the 'Exception' type.

 Is there a way to adapt 'syncExceptions' to work with
 'Control.Exception'?

 [1] 
 http://hackage.haskell.org/packages/archive/base/4.1.0.0/doc/html/Control-OldException.html

 ___
 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] Catch multiple exceptions using 'Control.Exception'

2013-07-03 Thread Nikita Karetnikov
 Perhaps you can use `catches` [0]?

Maybe, but my idea is to replace 'syncExceptions' with a similar
function.  Otherwise, it'll be necessary to change (at least) all
functions that use 'syncExceptions'.  I'd like to avoid that.


pgp3z2Qli9UKD.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Custom Setup.hs and Paths module

2013-07-03 Thread Daniel Díaz Casanueva
Hello Erik.

Yes, that solution may work, but seems ad-hoc to me. I would like to see a
way to actually import the Paths module. In the meanwhile, I will be using
your idea. Thank you for the response.

Anybody knows how to hack the Setup.hs so I can use the real Paths module?


On Wed, Jul 3, 2013 at 3:39 AM, Erik de Castro Lopo mle...@mega-nerd.comwrote:

 Daniel Díaz Casanueva wrote:

  Hi everyone.
 
  I am writing a package where I am using the Paths module that cabal
  generates automatically. After adding the Paths module to the
  other-modules section in my cabal file everything worked just fine,
 until
  I wanted to write a custom Setup.hs. This Setup.hs just writes a couple
 of
  files in the system and then calls defaultMain. The thing is that now
  cabal install does not find the Paths module, so the package is broken.

 I ran into the same problem. I ended up fixing it by *not* using the auto
 generated Paths module and instead parsing the cabal file in Setup.hs.

 This is not has horrible as it sounds as I used the Cabal insfrastructure
 to do it. Basically something like this:

 import Distribution.Simple
 import Distribution.PackageDescription
 import Distribution.PackageDescription.Parse (readPackageDescription)
 import Distribution.Verbosity (silent)

 version - fmap (showVersion . pkgVersion . package .
 packageDescription)
 $ readPackageDescription silent my-package.cabal

 and then used that version String to write a trivial 5 line file
 Version.hs.

 HTH,
 Erik
 --
 --
 Erik de Castro Lopo
 http://www.mega-nerd.com/

 ___
 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] ghci ghc - JS (Emscripten)

2013-07-03 Thread B B


 I think GHCJS should be able to compile all Haskell code in GHC, but we
 haven't tested this yet. The tricky bit is probably getting foreign code
 work, and creating a working installation that includes all other things,
 like libraries and a package database. Usually, GHCi loads object files for
 the libraries when running Haskell code. Obviously you can't run machine
 code with JavaScript, so you'd have to find a way around it. GHCJS includes
 an IO layer, which can be used to set up a virtual filesystem [2], but the
 API is far from finished.

Nice to hear that - we are concidering using GHCJS heavly in our project.
We dont have many people and this is free-time driven project for now,
but we would love to cooperate with you - help with GHCJS development and
work together to make it suitable for the project we are working on.



 Ah it's much easier if the code can be compiled on the server. This is
 more or less what Daniil Frumin is doing for his Google Summer of Code
 project [3]. We are using GHC on the server for non-interactive things, and
 GHCJS to compile interactive code that is run on the client. Our main goal
 is to get interactive graphics with the diagrams [4] library working.

Currently he is working on building a good sandbox for the compiler on the
 server (With SELinux, rlimits and cgroups) so that we can compile code, and
 run Template Haskell safely. I'm working on improving the GHCJS linker, so
 that we can support incremental code loading more easily (so users can
 download just the code for the new function they wrote, instead of the
 whole program every time)


That's very interesting. We want to use GHCJS EXACTLY for this - we want to
compile the code on the server and run it in the users browesr BUT we dont
want to load the whole program everytime a function is changed - only this
particular function.
Additional (which is NOT the same) - while writing a function - we want to
interactively execute it's body on the client side - but this requires
something like interpreter on the user client (please see below for
explanation). But we are thinking right now about it and its architecture,
so we will be in touch in this topic with you :)


I have a very crude example of this type here:

 http://hdiff.luite.com/reduce/


This is not exactly the kind of thing I'm talking about.
Think about something like matlab simulink or labview - functions are
representaed by nodes (rectangles) connected with other functions by
lines. Lines are sending data between these nodes.
So user is connecting these blocks - each block is like a function
application on data - so adding a block is like adding a new line in
Haskell .hs file. We want user to be able to interactively add such nodes
(apply further functions on already processed and cached data - every
node caches processed data) and process the data further - If I didn't
explained this simple enought, I will try harder. Such thing needs
something like client side interpreter I think ...


 When we have the SELinux sandbox working, I plan to work on this again, so
 that users can enter/compile their own code.


When do you plan roughtly to release it? We are strongly interested in
testing and using it :)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghci ghc - JS (Emscripten)

2013-07-03 Thread Brandon Allbery
On Wed, Jul 3, 2013 at 6:26 AM, B B blackbox.dev...@gmail.com wrote:

 Could you please answer one additional question - why you, while creating
 GHCJS didn't base on emscripten? Why haven't you patched it and created
 custom solution?


I'd like to point out that the LLVM code from GHC is CPS-transformed, and
this makes it a nightmare to work with. Already the LLVM optimizer pretty
much fails to do anything: optimizing CPS-transformed code is well-nigh
impossible without knowing what the pre-transformation code was, which
means a GHC-specific optimizer is necessary, or some way to communicate the
code's structure (LLVM actually supports annotations for this, but current
GHC doesn't generate them; I also would expect those annotations to go only
so far without GHC-specific tweaks to LLVM, and in fact I am under the
impression such tweaks have been proposed for inclusion in LLVM).

Similarly I would expect that generating any sort of sensible Javascript
would require something fairly tightly tied to GHC; otherwise the output's
going to have horrible performance because it's not going to understand the
input and will fall back to the slowest but most general translation. (If
it even has such a fallback, instead of simply failing on code that it
doesn't recognize.)

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghci ghc - JS (Emscripten)

2013-07-03 Thread Luite Stegeman
On Wed, Jul 3, 2013 at 3:13 PM, B B blackbox.dev...@gmail.com wrote:


 I think GHCJS should be able to compile all Haskell code in GHC, but we
 haven't tested this yet. The tricky bit is probably getting foreign code
 work, and creating a working installation that includes all other things,
 like libraries and a package database. Usually, GHCi loads object files for
 the libraries when running Haskell code. Obviously you can't run machine
 code with JavaScript, so you'd have to find a way around it. GHCJS includes
 an IO layer, which can be used to set up a virtual filesystem [2], but the
 API is far from finished.

 Nice to hear that - we are concidering using GHCJS heavly in our project.
 We dont have many people and this is free-time driven project for now,
 but we would love to cooperate with you - help with GHCJS development and
 work together to make it suitable for the project we are working on.


Great, if you want to help or discuss, you can come to #ghcjs on freenode.




This is not exactly the kind of thing I'm talking about.
 Think about something like matlab simulink or labview - functions are
 representaed by nodes (rectangles) connected with other functions by
 lines. Lines are sending data between these nodes.


I think it's possible to trap function application and show inputs and
outputs that way, but it might be tricky (maybe some patching required).
Also the generated optimized code can be quite different from the original
Haskell. There is lots of inlining, let floating and specialization, and
all functions that use typeclasses get extra parameters for the
dictionaries for example, so i guess trying to visualize everything
automatically will not give you the results you're after.

So user is connecting these blocks - each block is like a function
 application on data - so adding a block is like adding a new line in
 Haskell .hs file. We want user to be able to interactively add such nodes
 (apply further functions on already processed and cached data - every
 node caches processed data) and process the data further - If I didn't
 explained this simple enought, I will try harder. Such thing needs
 something like client side interpreter I think ...


You could let the user edit functions, then call back to the server and get
back graph nodes (and the code to run them of course), which could show the
name and the correct number of inputs. Actually connecting them would
require a typechecker though (and changing one connection can of course
make other connections invalid), perhaps through a server callback.

If you want to work with cached data, you probably want to use some special
thing to connect the functions, since Haskell code generally does not do
that. Perhaps FRP can be an inspiration here, where your graph editor wraps
pure Haskell functions (written by the user) in behaviours, and changing
values or behaviours propagates changes through the FRP network.



 When we have the SELinux sandbox working, I plan to work on this again,
 so that users can enter/compile their own code.


 When do you plan roughtly to release it? We are strongly interested in
 testing and using it :)


The current code is already on github, but it does not quite work yet (and
using it is not recommended until we are confident in the security of the
sandbox). Daniil will probably blog about it soon, and we should have a
public beta within a month.

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


Re: [Haskell-cafe] How to use Template Haskell based on code that generated by another Template?

2013-07-03 Thread adam vogt
On Wed, Jul 3, 2013 at 2:25 AM, Magicloud Magiclouds
magicloud.magiclo...@gmail.com wrote:
 Then I got
 Illegal variable name: `UserPassword'
 When splicing a TH declaration:

Hi Magicloud,

GHC seems to be trying to tell you that variables are lowercase in
haskell. Since you don't have code, I'm guessing your error is from
doing something like:

 wrong1 = print ($(dyn Just) 5)
 wrong2 = print ($(varE 'Just) 5)

Which is a compile time error since you apparently can't pass a Name
which is capitalized to `VarE :: Name - Exp'

Any of these options work. They use the  `ConE :: Name - Exp'
constructor instead:

 opt1 = print ($(conE (mkName Just)) 5)
 opt2 = print ($(conE 'Just) 5)
 opt3 = print ($( [| Just |]) 5 )

--
Adam

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


Re: [Haskell-cafe] ghci ghc - JS (Emscripten)

2013-07-03 Thread Luite Stegeman
 Similarly I would expect that generating any sort of sensible Javascript
 would require something fairly tightly tied to GHC; otherwise the output's
 going to have horrible performance because it's not going to understand the
 input and will fall back to the slowest but most general translation. (If
 it even has such a fallback, instead of simply failing on code that it
 doesn't recognize.)


Emscripten produces a limited subset of JavaScript (asm.js), and Firefox
has an optimizer specifically for that. It could result in good
performance, but the CPS transformed code is still a problem indeed, so
it's unclear if GHC generated code would work at all.

Asm.js is really limited, it's like a far less convenient LLVM without
modern instructions in JavaScript syntax. You can't use objects, everything
is stored in a global heap array.

Interestingly, Firefox performs far worse than Chrome and Safari on the
current GHCJS code, probably because their garbage collector is rather poor
(non-generational), and Haskell code produces lots of short-lived immutable
objects.

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


[Haskell-cafe] GHC 7.8 (GHCJS)

2013-07-03 Thread B B
Hi, on the GHCJS website () I found an information:

If you are from the future, you have GHC 7.8 or higher installed, and Cabal
1.18, run the following:
$ cabal install ghcjs
$ ghcjs-boot --auto

Is it possible currently to get somehow GHC 7.8 or this information means
that AFTER release of 7.8 this functionality will be available?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC 7.8 (GHCJS)

2013-07-03 Thread Luite Stegeman
That's just a joke, because GHCJS is a bit tricky to install, but it will
be easier after 7.8 is released and they have merged our patches (unless
you really are from the future, then you can just install it, but please
send me the code of all the bugs i'll have fixed by then).

The easiest way to get up and running is a virtual machine with GHC HEAD,
see this for some introduction and installation instructions:
http://weblog.luite.com/wordpress/?p=14

For working on a VM, the vado tool might be useful:
http://parenz.wordpress.com/2013/06/29/vado/

luite



On Wed, Jul 3, 2013 at 5:53 PM, B B blackbox.dev...@gmail.com wrote:

 Hi, on the GHCJS website () I found an information:

 If you are from the future, you have GHC 7.8 or higher installed, and
 Cabal 1.18, run the following:
 $ cabal install ghcjs
 $ ghcjs-boot --auto

 Is it possible currently to get somehow GHC 7.8 or this information means
 that AFTER release of 7.8 this functionality will be available?

 ___
 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] ghci ghc - JS (Emscripten)

2013-07-03 Thread Daniel Frumin


On Jul 3, 2013, at 5:13 PM, B B blackbox.dev...@gmail.com wrote:

 
 I think GHCJS should be able to compile all Haskell code in GHC, but we 
 haven't tested this yet. The tricky bit is probably getting foreign code 
 work, and creating a working installation that includes all other things, 
 like libraries and a package database. Usually, GHCi loads object files for 
 the libraries when running Haskell code. Obviously you can't run machine 
 code with JavaScript, so you'd have to find a way around it. GHCJS includes 
 an IO layer, which can be used to set up a virtual filesystem [2], but the 
 API is far from finished.
 Nice to hear that - we are concidering using GHCJS heavly in our project. We 
 dont have many people and this is free-time driven project for now, but we 
 would love to cooperate with you - help with GHCJS development and work 
 together to make it suitable for the project we are working on.
 
  
 Ah it's much easier if the code can be compiled on the server. This is more 
 or less what Daniil Frumin is doing for his Google Summer of Code project 
 [3]. We are using GHC on the server for non-interactive things, and GHCJS to 
 compile interactive code that is run on the client. Our main goal is to get 
 interactive graphics with the diagrams [4] library working.
 Currently he is working on building a good sandbox for the compiler on the 
 server (With SELinux, rlimits and cgroups) so that we can compile code, and 
 run Template Haskell safely. I'm working on improving the GHCJS linker, so 
 that we can support incremental code loading more easily (so users can 
 download just the code for the new function they wrote, instead of the whole 
 program every time)
 
 That's very interesting. We want to use GHCJS EXACTLY for this - we want to 
 compile the code on the server and run it in the users browesr BUT we dont 
 want to load the whole program everytime a function is changed - only this 
 particular function. 
 Additional (which is NOT the same) - while writing a function - we want to 
 interactively execute it's body on the client side - but this requires 
 something like interpreter on the user client (please see below for 
 explanation). But we are thinking right now about it and its architecture, so 
 we will be in touch in this topic with you :)
  
 
 I have a very crude example of this type here:
 
 http://hdiff.luite.com/reduce/
 
 This is not exactly the kind of thing I'm talking about. 
 Think about something like matlab simulink or labview - functions are 
 representaed by nodes (rectangles) connected with other functions by lines. 
 Lines are sending data between these nodes. 
 So user is connecting these blocks - each block is like a function 
 application on data - so adding a block is like adding a new line in Haskell 
 .hs file. We want user to be able to interactively add such nodes (apply 
 further functions on already processed and cached data - every node caches 
 processed data) and process the data further - If I didn't explained this 
 simple enought, I will try harder. Such thing needs something like client 
 side interpreter I think ...
  
 When we have the SELinux sandbox working, I plan to work on this again, so 
 that users can enter/compile their own code.
 
 When do you plan roughtly to release it? We are strongly interested in 
 testing and using it :) 

As Luite has pointed out we plan on releasing the first public beta within a 
month and we are hoping to ship full-featured easily extensible documented 
version by the end of the summer. 


 ___
 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] Custom Setup.hs and Paths module

2013-07-03 Thread Erik de Castro Lopo
Daniel Díaz Casanueva wrote:

 Hello Erik.
 
 Yes, that solution may work, but seems ad-hoc to me. I would like to see a
 way to actually import the Paths module. In the meanwhile, I will be using
 your idea. Thank you for the response.
 
 Anybody knows how to hack the Setup.hs so I can use the real Paths module?

I'm almost certain it can't be done.

The problem is that the Paths module is generated by the 'cabal configure'
process and the configure process needs to run Setup.hs which needs the
Paths module etc etc.

That's what you might call a circular dependency :-).

Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/

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


Re: [Haskell-cafe] Catch multiple exceptions using 'Control.Exception'

2013-07-03 Thread Roman Cheplyaka
* Nikita Karetnikov nik...@karetnikov.org [2013-07-03 15:50:16+0400]
  Perhaps you can use `catches` [0]?
 
 Maybe, but my idea is to replace 'syncExceptions' with a similar
 function.  Otherwise, it'll be necessary to change (at least) all
 functions that use 'syncExceptions'.  I'd like to avoid that.

Here you go:

  import Control.Exception
  import Data.Typeable

  syncExceptions :: SomeException - Maybe SomeException
  syncExceptions e
| Just _ - cast e :: Maybe AsyncException = Nothing
| otherwise = Just e

Roman

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


[Haskell-cafe] Haskell Weekly News: Issue 272

2013-07-03 Thread Daniel Santa Cruz
Welcome to issue 272 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of June 23 to 29, 2013.

Quotes of the Week

   * kmc: johnw: I'm rejoining this channel after months away just to
 tell you how incredibly wrong you are that monads are the core
 concept of Haskell

   * dmwit: semigroups are monoids with an identity crisis

   * olsner: I think doing eta something means to make it more or less
 pointless. But I don't recall which eta does what

   * mm_freak: Oleg knows what's at the end of foldr f z [1..].

   * copumpkin: it's like grasping desperately for the rope of induction
 as you fall down the bottomless pit of coinduction

Top Reddit Stories

   * From zero to cooperative threads in 33 lines of Haskell code
 Domain: haskellforall.com, Score: 78, Comments: 39
 On Reddit: [1] http://goo.gl/rtkrO
 Original: [2] http://goo.gl/wgyAC

   * RSS reader written in Haskell and Ur/Web
 Domain: bazqux.com, Score: 66, Comments: 38
 On Reddit: [3] http://goo.gl/sUw1U
 Original: [4] http://goo.gl/gdh5G

   * FP Haskell Center -- full video demo -- app development, automatic
deployment, Git and GitHub integration
 Domain: youtube.com, Score: 64, Comments: 68
 On Reddit: [5] http://goo.gl/gBi5l
 Original: [6] http://goo.gl/TlGL9

   * Building LLVM using Shake
 Domain: neilmitchell.blogspot.ca, Score: 54, Comments: 6
 On Reddit: [7] http://goo.gl/38rWZ
 Original: [8] http://goo.gl/tA5tM

   * Hasochism: The Pleasure and Pain of Dependently Typed Haskell
Programming [pdf]
 Domain: personal.cis.strath.ac.uk, Score: 52, Comments: 8
 On Reddit: [9] http://goo.gl/6dDsL
 Original: [10] http://goo.gl/ZZPZL

   * GHC Core by example, episode 1 - Hello Core!
 Domain: alpmestan.com, Score: 46, Comments: 3
 On Reddit: [11] http://goo.gl/iL5ho
 Original: [12] http://goo.gl/mUiO5

   * HPCwire: Lustre Founder Spots Haskell on HPC Horizon
 Domain: hpcwire.com, Score: 36, Comments: 2
 On Reddit: [13] http://goo.gl/h2dmv
 Original: [14] http://goo.gl/1WLf8

   * Adventures in Three Monads - Logic, Prompt, Failure
 Domain: web.mit.edu, Score: 33, Comments: 8
 On Reddit: [15] http://goo.gl/JEOfw
 Original: [16] http://goo.gl/AI5wV

   * Darcs' source code is some of the cleanest Haskell I've read in a while
 Domain: github.com, Score: 32, Comments: 13
 On Reddit: [17] http://goo.gl/TWWMh
 Original: [18] http://goo.gl/fZGE8

   * I accidentally the entire heap: debugging Haskell programs with space
leaks
 Domain: bitba.se, Score: 32, Comments: 6
 On Reddit: [19] http://goo.gl/9Vtzy
 Original: [20] http://goo.gl/HCS5N

   * GHCJS introduction – Concurrent Haskell in the browser
 Domain: weblog.luite.com, Score: 30, Comments: 4
 On Reddit: [21] http://goo.gl/Fk8Xd
 Original: [22] http://goo.gl/8CUVT

   * Functional Reactive Web Interfaces with GHCJS and sodium
 Domain: weblog.luite.com, Score: 29, Comments: 12
 On Reddit: [23] http://goo.gl/5QKn0
 Original: [24] http://goo.gl/VpAOv

   * Who Ya Gonna Call? Getting Dirty with Cmm, the GHC backend, and
writing new PrimOps with Carter Schonwald (at NY-Haskell)
 Domain: vimeo.com, Score: 26, Comments: 14
 On Reddit: [25] http://goo.gl/wUVcs
 Original: [26] http://goo.gl/cZaGd

   * Business system using functional programming?
 Domain: self.haskell, Score: 24, Comments: 44
 On Reddit: [27] http://goo.gl/QcE5P
 Original: [28] http://goo.gl/QcE5P

   * The Resource Applicative
 Domain: haskellforall.com, Score: 23, Comments: 16
 On Reddit: [29] http://goo.gl/G7TIs
 Original: [30] http://goo.gl/4e0Gm


Top StackOverflow Questions

   * What's the conceptual difference between Machines and Conduits (or
other similar libraries)?
 votes: 13, answers: 1
 Read on SO: [31] http://goo.gl/hrNMl

   * “inject” progress logging/tracing in haskell computation?
 votes: 13, answers: 2
 Read on SO: [32] http://goo.gl/RdEKU

   * Difference between free monads and fixpoints of functors?
 votes: 12, answers: 0
 Read on SO: [33] http://goo.gl/O3oBi

   * Can Haskell optimize function calls the same way Clang / GCC does?
 votes: 12, answers: 3
 Read on SO: [34] http://goo.gl/Sgf88

   * Trying to figure out `random` function in Haskell
 votes: 10, answers: 3
 Read on SO: [35] http://goo.gl/kcHsi

   * What does !( ) means in data constructor?
 votes: 9, answers: 2
 Read on SO: [36] http://goo.gl/ysnNL

   * Anything prevents optimizing tail-recursion?
 votes: 9, answers: 1
 Read on SO: [37] http://goo.gl/LaTY2

   * Where can I find a good introduction to Haskell optimization passes?
 votes: 9, answers: 1
 Read on SO: [38] http://goo.gl/wMYQH

   * Passing void * through haskell
 votes: 9, answers: 1
 Read on SO: [39] http://goo.gl/Fiu5Q

   * Call main function 

[Haskell-cafe] bug in Data.ByteString.Lazy or in me?

2013-07-03 Thread John MacFarlane
On a 64-bit Windows 8 server EC2 instance, with Haskell Platform
freshly installed from the package installer,

GHCI :m + Data.ByteString.Lazy
GHCI Data.ByteString.Lazy.hGetContents stdin

gives me an immediate error hGetBufSome: resource exhausted (Not enough
space), while

GHCI :m + Data.ByteString
GHCI Data.ByteString.hGetContents stdin

waits for user input, as expected.

On 32-bit Windows, both work as expected.

Can anyone explain this?  Is this a bug in bytestring?

John


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


[Haskell-cafe] Product-Categories

2013-07-03 Thread Lyndon Maydwell
Hi Café.

I'm wracking my brain trying to figure out a simple, reasonably general,
implementation for a category instance for pairs of categories.

So far I've looked at [1], which seems great, but doesn't use the built-in
category instance, and [2], which I'm just not sure about.

Ideally I'd like to be able to express something like -

instance (Category a, Category b) = Category (Product a b) where
id = Product id id
Product o1 o2 . Product i1 i2 = Product (o1 . i1) (o2 . i2)

However, it all falls apart when I actually try to define anything. Is this
possible? If not, why not?

As far as I can tell the issue boils down to not being able to translate
Category i o to Product (Fst i) (Fst o) (Snd i) (Snd o) without
breaking the kind expectation of the category instance.

Please help me, I'm having a bad brain day :-)


[1] - http://twanvl.nl/blog/haskell/categories-over-pairs-of-types
[2] -
http://hackage.haskell.org/packages/archive/categories/1.0.6/doc/html/Control-Category-Cartesian.html#t:Product
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to use Template Haskell based on code that generated by another Template?

2013-07-03 Thread Magicloud Magiclouds
Yes, I misunderstood the generated code and splice shown in error message.
Thanks.


On Wed, Jul 3, 2013 at 11:04 PM, adam vogt vogt.a...@gmail.com wrote:

 On Wed, Jul 3, 2013 at 2:25 AM, Magicloud Magiclouds
 magicloud.magiclo...@gmail.com wrote:
  Then I got
  Illegal variable name: `UserPassword'
  When splicing a TH declaration:

 Hi Magicloud,

 GHC seems to be trying to tell you that variables are lowercase in
 haskell. Since you don't have code, I'm guessing your error is from
 doing something like:

  wrong1 = print ($(dyn Just) 5)
  wrong2 = print ($(varE 'Just) 5)

 Which is a compile time error since you apparently can't pass a Name
 which is capitalized to `VarE :: Name - Exp'

 Any of these options work. They use the  `ConE :: Name - Exp'
 constructor instead:

  opt1 = print ($(conE (mkName Just)) 5)
  opt2 = print ($(conE 'Just) 5)
  opt3 = print ($( [| Just |]) 5 )

 --
 Adam




-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Call for Demo Proposals: Workshop on Functional Art, Music, Modeling and Design

2013-07-03 Thread Brent Yorgey
Hi all,

Below is the call for demonstration proposals for FARM 2013.  Please
forward to anyone who might be interested -- apologies if you receive
multiple copies!

Brent Yorgey
publicity chair for FARM 2013


==
  FARM 2013: Call for Demo Proposals

  ACM SIGPLAN Workshop on Functional Art, Music, Modeling and Design
  Boston, Massachusetts, USA
  28th September, 2013 (directly after ICFP)

  http://www.cis.upenn.edu/~byorgey/farm13/
==


Do you enjoy writing beautiful code to produce beautiful artifacts? Have
something cool to show off at the intersection of functional programming
and visual art, music, sound, modeling, visualization, or design?

FARM 2013 is seeking proposals for 10-20 minute demonstrations to be
given during the workshop. For example, a demonstration could consist of
a short tutorial, an exhibition of some work, or even a livecoding
performance. Slots for demonstrations will be shorter than slots for
accepted papers, and will not be published as part of the formal
proceedings, but can be a great way to show off interesting work and get
feedback from other workshop participants. A demonstration slot could be
a particularly good way to get feedback on work-in-progress.

Scope
-

The functional programming community is largely interested in writing
beautiful programs. This workshop is intended to gather researchers and
practitioners interested in writing beautiful programs that generate
beautiful artifacts. Such artifacts may include visual art, music, 3D
sculptures, animations, GUIs, video games, physical models,
architectural models, choreographies for dance, poetry, and even
physical objects such as VLSI layouts, GPU configurations, or mechanical
engineering designs. The framework used need not be purely functional
(“mostly functional” is fine); may be based on abstractions such as
higher-order functions, monads, arrows, or streams; and may be
manifested as a domain specific language or tool. Theoretical
foundations, language design, implementation issues, and applications
are all within the scope of the workshop.

Important dates
---

-   Demonstration proposals due: Wednesday, 31 July 2013, 18:00 EDT
(UTC-4)

-   Author notification: Monday, 5 August 2013

-   Workshop: Saturday, 28 September 2013 (the day after ICFP)

A demo proposal should consist of a 1 page abstract, in PDF format,
explaining the proposed content of the demonstration and why it would be
of interest to the attendees of FARM. Proposals will be judged on
interest and relevance to the stated goals and themes of the workshop.

Submissions can be made via EasyChair at
https://www.easychair.org/conferences/?conf=farm2013.

Organizers
--

Workshop Chair: Paul Hudak
Program Chair: Conal Elliott
Publicity Chair: Brent Yorgey

Program Committee
-

Daniel Cukier (University of São Paulo)
Conal Elliott (Tabula) (chair)
Kathleen Fisher (Tufts University)
Richard Gabriel (IBM Research)
George Giorgidze (University of Tübingen)
Paul Hudak (Yale University)
José Pedro Magalhães (University of Oxford)
Alex McLean (University of Leeds)
John Peterson (Western State Colorado University)
Michael Sperber (Active Group)
Henning Thielemann
Brent Yorgey (University of Pennsylvania)

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