Re: [Haskell-cafe] Need some advice around lazy IO

2013-03-23 Thread mukesh tiwari
Hi Kashyap
I am not sure if this solution to your problem but try using Bytestring
rather than String in

parseXML' :: String - XMLAST
parseXML' str =
  f ast where
  ast = parse (spaces  xmlParser)  str
  f (Right x) = x
  f (Left x) = CouldNotParse


Also see this post[1] My Space is Leaking..

Regards,
Mukesh Tiwari

[1] http://www.mega-nerd.com/erikd/Blog/


On Sat, Mar 23, 2013 at 11:11 AM, C K Kashyap ckkash...@gmail.com wrote:

 Oops...I sent out the earlier message accidentally.

 I got some profiling done and got this pdf generated. I see unhealthy
 growths in my XML parser.
 https://github.com/ckkashyap/haskell-perf-repro/blob/master/RSXP.hs
 I must be not using parsec efficiently.

 Regards,
 Kashyap




 On Sat, Mar 23, 2013 at 11:07 AM, C K Kashyap ckkash...@gmail.com wrote:

 I got some profiling done and got this pdf generated. I see unhealthy
 growths in my XML parser.



 On Fri, Mar 22, 2013 at 8:12 PM, C K Kashyap ckkash...@gmail.com wrote:

 Hi folks,

 I've run into more issues with my report generation tool  I'd really
 appreciate some help.

 I've created a repro project on github to demonstrate the problem.
 git://github.com/ckkashyap/haskell-perf-repro.git

 There is a template xml file that needs to be replicated several times
 (3000 or so) under the data directory and then driver needs to be run.
 The memory used by driver keeps growing until it runs out of memory.

 Also, I'd appreciate some tips on how to go about debugging this
 situation. I am on the windows platform.


 Regards,
 Kashyap


 On Tue, Mar 19, 2013 at 1:11 PM, Kim-Ee Yeoh k...@atamo.com wrote:

 On Tue, Mar 19, 2013 at 2:01 PM, Konstantin Litvinenko
 to.darkan...@gmail.com wrote:
  Yes. You (and Dan) are totally right. 'Let' just bind expression, not
  evaluating it. Dan's evaluate trick force rnf to run before hClose.
 As I
  said - it's tricky part especially for newbie like me :)

 To place this in perspective, one only needs to descend one or two
 more layers before the semantics starts confusing even experts.

 Whereas the difference between seq and evaluate shouldn't be too hard
 to grasp, that between evaluate and (return $!) is considerably more
 subtle, as Edward Yang notified us 10 days ago. See the thread titled
 To seq or not to seq.

 -- Kim-Ee

 ___
 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 mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Compiled code

2013-03-23 Thread Krzysztof Skrzętnicki
They are used: any library installed with e.g. cabal-install is kept around
not in source form but with .hi and .o files (and perhaps some metadata as
well.)

Best regards,
Krzysztof Skrzętnicki


On Fri, Mar 22, 2013 at 11:04 PM, MigMit miguelim...@yandex.ru wrote:

 Suppose I compiled some module and kept it's .hi and .o files. Is it
 possible to use this module in my program if the source code was deleted
 for some reason?

 Seems like the answer is yes — by creating a fake .hs file (with no real
 content) and touch-in .hi and .o files I tricked ghc so that it didn't
 attempt to recompile the module, so the information in .hi and .o files is
 sufficient. But ghc insists on having the .hs file around, and I didn't
 find a way to turn it off. Is there any? Or there is a specific reason not
 to allow this?
 ___
 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] Announcement - HGamer3D - 0.2.1 - why netwire

2013-03-23 Thread Heinrich Apfelmus

Peter Althainz wrote:

Heinrich Apfelmus wrote:


Of course, I have to ask: what influenced your choice of FRP library in
favor of  netwire  instead of  reactive-banana ?


good question, actually I need to thank you for your excellent tutorials
on FRP and GUI on the WEB. I tried the version of reactive-banana
without switches as the first FRP framework to have contact with and I
liked its simplicity and the cool introduction around Excel cells you 
gave on the Web.


My pleasure. :) I have to thank Peter Minten for writing the tutorial 
with Excel cells, though.



HGamer3D is my personal way to get more insight into FP and Haskell
especially and from the beginning I wanted to have a FRP API to try it
with game examples. So your intro on FRP and the examples were very
helpful with that.

After reading a lot on the web it became clear, that currently
reactive-banana and netwire are good candidates to start with. So why in
the end I decided to use netwire for the binding?

It's some personal things and I do not claim to have done a proper
evaluation or comparison. I also cannot judge on performance or other
relevant topics. Having said that, I can give you some points why I 
choosed netwire:

- The cool simplicity of reactive-banana API seems to have suffered a
little bit after the introduction of the switch functionality.
- After getting around Monads and Applicative by great help of Learning
a Haskell for great good I was shocked to see, there is even more to
learn, when I detected Arrows. So I started to look at it and discovered
some nice tutorials for Arrows.
- What struck me was introduction of netwire author Ertugrul Söylemez on
Arrows and the explanations of local state, which can be kept into an
arrow. Since I was also curious on OOP and FP and game state handling,
actually this raised some interest. So I think this Arrows keep local
state argument was the killer feature. But also behaviours keep
local state and maybe I got misguided here.
- I then did some trials with netwire and I felt it's a quite
comprehensive and nice API, so I got started with that.


I'm mainly asking because it helps me learn about issues with 
reactive-banana that could be fixed. Looking at other FRP libraries for 
fun and learning is definitely something that should be encouraged and 
not something that should be fixed, so that's cool. :)


You said that reactive-banana didn't feel as simple after the 
introduction of dynamic event switching, though. Could you pinpoint some 
particular thing that made you feel like that? Maybe a type signature or 
a tutorial or something else? I took great care trying to make the 
dynamic event switching stuff entirely optional, so you can use 
reactive-banana without understanding it at all, but I'm not sure if I 
succeeded.



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


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


Re: [Haskell-cafe] Ticking time bomb

2013-03-23 Thread Jon Fairbairn
Marc Weber marco-owe...@gmx.de writes:

 The only safe way is acceptnig keys from people you know don't view pdf
 using adobe reader,

I don’t…

 who don't browse the web (neither use flash) etc.

I only browse the web (in general) from a diskless virtual
machine.

 And then still you also have to know that their email account password
 is reasonable strong ..

I don’t think you need to know that: you need to know that their
signing key password is strong, that they’ve never entered it
into a machine with a keylogger running, and no-one has shoulder
surfed them. Oh, and that no-one can blackmail or torture them
:-P

-- 
Jón Fairbairn jon.fairba...@cl.cam.ac.uk


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


Re: [Haskell-cafe] Announcement - HGamer3D - 0.2.1 - why netwire

2013-03-23 Thread Ertugrul Söylemez
Heinrich Apfelmus apfel...@quantentunnel.de wrote:

 You said that reactive-banana didn't feel as simple after the
 introduction of dynamic event switching, though. Could you pinpoint
 some particular thing that made you feel like that? Maybe a type
 signature or a tutorial or something else? I took great care trying to
 make the dynamic event switching stuff entirely optional, so you can
 use reactive-banana without understanding it at all, but I'm not sure
 if I succeeded.

I think this is less of an issue with reactive-banana than with classic
FRP in general.  The type signatures of Netwire can be scary at first
sight, but they are consistent throughout the entire library.  Once you
understand one of these type signatures you understand all of them.
Once you know how to use one wire, you know how to use all others.

Let me pinpoint something in particular: events.  In reactive-banana
events are special, in Netwire they are not.  This makes dynamic
switching special in reactive-banana and natural in Netwire.  Let me
show you an example:  You want to dispaly one for ten seconds, then
two for twelve seconds, then start over:

myWire =
one . for 10 --
two . for 12 --
myWire

Events and particularly dynamic event switching is one of the main
problems Netwire solves elegantly.  You can add this to reactive-banana,
too, but it would require changing almost the entire event interface.


Greets,
Ertugrul

-- 
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.


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


Re: [Haskell-cafe] A question about data declaration

2013-03-23 Thread Doug Burke
On Mar 22, 2013 2:58 AM, C K Kashyap ckkash...@gmail.com wrote:

 Thanks Eric and Brent,

 Even with GADT, it appears that I'd need extra data definitions. I'll go
without GADT then ...

 Brent, my use case is not particularly complicated. I am trying to model
the pdf spec - which says that pdf contains Objects that could of of types
Number, String, Name, Array and Dictionary - while array is list of
objects, the Disctionary is a list of tuples (Name, Object) not (Object,
Object) - hence my situation.

 Regards,
 Kashyap


You could have a look at how the aeson package represents JavaScript
values, which have a similar structure to your requirement, e.g.
http://hackage.haskell.org/packages/archive/aeson/0.6.1.0/doc/html/Data-Aeson-Types.html#t:Value

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


[Haskell-cafe] ANN: pdf-toolbox

2013-03-23 Thread Yuras Shumovich
Hello,

I have uploaded the first release of my pdf toolbox, a collection of
tools for processing PDF files. It supports both parsing and generating
of pdf files.

It consists of two libraries:
  - core ( http://hackage.haskell.org/package/pdf-toolbox-core )
contains low level tools.
  - document ( http://hackage.haskell.org/package/pdf-toolbox-document )
contains pretty limited set of middle level tools.

(Also there is the 3d library, pdf-toolbox-content. It contains tools
for processing pdf page content, e.g. text extraction. It is not
released yet, but you can find it on github.)

The initial plan was to create higher level tools before releasing on
hackage, but I found it hard to design good high level API without wide
rage on use cases. So I decided to release it earlier in order to
receive feedback.

You can find few examples here:
https://github.com/Yuras/pdf-toolbox/tree/master/examples

Thanks,
Yuras



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


Re: [Haskell-cafe] A question about data declaration

2013-03-23 Thread Evan Laforge
 Brent, my use case is not particularly complicated. I am trying to model the
 pdf spec - which says that pdf contains Objects that could of of types
 Number, String, Name, Array and Dictionary - while array is list of objects,
 the Disctionary is a list of tuples (Name, Object) not (Object, Object) -
 hence my situation.

The WASH web framework used a trick to type HTML.  If I recall
correctly, they had a couple of phantom type parameters and then wrote
MPTC instances for only the allowed combinations.  So you'd have HTML
InXContext OrderedList and HTML InXContext UnorderedList, etc.
Then the constructor for an X would have a type signature that
required 'HTML InXContext a' of its argument.

Or something like that.  See if you can dig up any old WASH docs for
more details.

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


[Haskell-cafe] Enumerating functions at runtime

2013-03-23 Thread Luke Evans
I'm curious about using Haskell for metaprogramming.

It looks like I can dynamically compile, load and run some Haskell with the 
plugins package.  Actually I've briefly tried this and it seems to work for 
some simple cases at least.
Now I would like to be able to enumerate precompiled public functions in 
modules that I might use as building blocks in such dynamic compilation.  So 
far I'm not seeing anything that does this directly.
Can anyone provide some pointers?

If it's just not possible to introspect on compiled modules, then I suppose I 
could use external metadata of my own, or even perhaps haddock info if it 
exists, to attempt to generate this info.  Clearly though, that's nowhere near 
as good as extracting the info from something the compiler built directly.



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


Re: [Haskell-cafe] Enumerating functions at runtime

2013-03-23 Thread Brandon Allbery
On Sat, Mar 23, 2013 at 11:26 PM, Luke Evans l...@eversosoft.com wrote:

 I'm curious about using Haskell for metaprogramming.

 It looks like I can dynamically compile, load and run some Haskell with
 the plugins package.  Actually I've briefly tried this and it seems to work
 for some simple cases at least.
 Now I would like to be able to enumerate precompiled public functions in
 modules that I might use as building blocks in such dynamic compilation.
  So far I'm not seeing anything that does this directly.
 Can anyone provide some pointers?


I'm not aware of any canned solutions, but one way you could do it is to
enumerate the symbol table of a compiled module and z-decode symbols;
functions get their types z-encoded into their symbol table names. A more
likely useful way is to extract them from the .hi file; there should be
functions in ghc-api and likely in hint to do this, since the compiler must
do so as part of importing a module; or at worst, you can use ghc
-print-iface to decode a .hi file to text and extract the information that
way.

-- 
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