Re: [Haskell-cafe] Dual-licensing the package on Hackage

2013-07-30 Thread Krzysztof Skrzętnicki
Perhaps it would be best if .cabal allowed to have more than one license
listed.

Another solution would be to use custom field, for example:

License: GPL
x-Other-License: Commercial, see License-Commercial.txt

All best,
Krzysztof Skrzętnicki

On Tue, Jul 30, 2013 at 11:44 AM, David Sorokin david.soro...@gmail.comwrote:

 Thanks Thu,

 I agree with you. Just I don't know what to write in the license field of
 the .cabal file: GPL or OtherLicense. The both choices seem correct to me
 and misleading at the same time.

 Cheers,
 David

 30.07.2013, в 12:53, Vo Minh Thu написал(а):

  2013/7/30 David Sorokin david.soro...@gmail.com:
  Hi, Cafe!
 
  Probably, it was asked before but I could not find an answer with help
 of Google.
 
  I have a library which is hosted on Hackage. The library is licensed
 under BSD3. It is a very specialized library for a small target group. Now
 I'm going to relicense it and release a new version already under the
 dual-license: GPLv3 and commercial. In most cases GPL will be sufficient as
 this is not a library in common sense.
 
  Can I specify the GPL license in the .cabal file, or should I write
 OtherLicense?
 
  I'm going to add the information about dual-licensing in the
 description section of the .cabal file, though.
 
  Although you can indeed license your software under different
  licences, in the case of your question it doesn't seem to be a concern
  with Hackage:
 
  The license displayed on Hackage is the one for the corresponding
  .cabal file (or at least I think it is). So you issue your new version
  with the changed license, the new version is available with the new
  license, the old versions are still available with the old license.
  Everything is fine.
 
  Now about the dual licensing. It seems it is again not a problem with
  Hackage: you are not granting through Hackage such a commercial
  license. I guess you provide it upon request (for some money). I.e.
  when I download your library from Hackage, I receive it under the
  terms of the BSD (or GPL) license you have chosen, not under a
  commercial license that I would have to receive through other means.
 
  Otherwise the semantic of the license field on Hackage would mean the
  library is available under such and such licenses, which are not
  granted to you when you download the library on Hackage. Only when you
  download the package you can actually find the licensing terms (e.g.
  in the LICENSE file). But this seems unlikely to me.
 
  Cheers,
  Thu


 ___
 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] Performance difference between Linux and Windows?

2013-05-31 Thread Krzysztof Skrzętnicki
The difference is roughly 2x, which suggests difference in Int/pointer
sizes: 32bit vs 64bit. Indeed, only since 7.6.1. GHC supports compiling 64
bit executables on Windows (
http://hackage.haskell.org/trac/ghc/wiki/WindowsGhc). That means that in
fact you compare 32 bit vs 64 bit programs.

I didn't have a look at the code so this is just a wild guess.

Best regards,
Krzysztof Skrzętnicki

On Fri, May 31, 2013 at 3:26 PM, James Jones jejones3...@gmail.com wrote:

 I've been having a great deal of fun writing a program to solve this
 year's Code Jam Fair and Squareproblem in Haskell (and learning about
 Haskell in the process). Having gotten it to work, I've been optimizing it
 as best I can. I'm not quite in Captain Ahab mode, but before I let it go I
 would like to find out what's behind a difference I've seen compiling and
 running the program under Linux and under Windows 7.

 Profiling it under Linux (compiled with GHC 7.4.1), it had a total
 allocation of 165,375,112 bytes. I had an opportunity to compile and run on
 Windows 7, with GHC 7.4.2. I expected it to run faster, since the Windows
 computer had a 3.1 GHz i7 and my Linux computer has a 2.8 GHz AMD Propus,
 but what I didn't expect was that the total allocation on the Windows
 version was 88,438,372 bytes!

 Thinking it might be due to a compiler improvement, I upgraded my Linux
 computer to Ubuntu 13.04 so I could get a newer GHC, but it didn't make
 much difference: total allocation 163,248,688 bytes.

 So, I'm wondering: what is it about either the Windows implementation or
 GHC 7.4.2 in particular that would make a factor of two difference in
 memory allocation? Should anyone wish to compile the program, let me know
 the best way to make the source available and I will happily do so; I also
 use Twan van Laarhoven's semilattice search tree code available at
 http://twanvl.nl/blog/haskell/SemilatticeSearchTree.

 James Jones

 ___
 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] using a win32 dll

2013-05-29 Thread Krzysztof Skrzętnicki
My first guess would be missing -l parameter. The examples you have linked
read:

ghc --make compname.hs -lkernel32


Best regards,
Krzysztof Skrzętnicki

On Wed, May 29, 2013 at 9:13 AM, Kees Bleijenberg 
k.bleijenb...@lijbrandt.nl wrote:

 I made a Delphi dll (32 bits windows). This dll exports a function named
 getPngVersion. This is a function with no arguments that returns a pointer
 to a array of chars.

 If I examine the dll with a tools like tdump, I can see the function
 getPngVersion on index 1.

 Now I want to use this dll in Haskell:

 ** **

 {-# LANGUAGE ForeignFunctionInterface #-}

 module Main(

 main

 )

 ** **

 where

 import Control.Monad

 import Foreign.C

 import Foreign.Marshal.Alloc

 import Foreign.Marshal.Array

 import System.Win32.Types

 ** **

 foreign import stdcall glasPng getPngVersion  getPngDllVersion :: IO
 CString

 ** **

 main :: IO ()

 main = do 

  s - getPngDllVersion

  putStrLn (show s)

 ** **

 Compiling this with ghc --make glasPng.hs gives:

 GlasPng.o: fake: (.text +0x82): undefined reference to  ‘getPngVersion@0’
 collect2 : Id returned 1 exit status 

 ** **

 I wonder what went wrong. In the foreign import line I use “glasPng…. “ to
 tell ghc, it has to searh in glasPng.dll (changing glasPng to glasPng.dll
 doesn’t help). I’ve changed the name of the function in  the dll to
 getPngVersion@0 but no luck.  I’ve read and tested the last example at
 http://stackoverflow.com/questions/1027246/haskell-foreign-import-stdcall-on-dll-function
 (win32_getComputername,  this works!). I wonder how  haskell knows which
 dll to use in this example?)

 Probably I’am doing something wrong with the way I tell ghc which dll to
 link or….

 ** **

 Any ideas?

 ** **

 Kees

 ___
 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] Reinventing a solution to configuration problem

2013-05-09 Thread Krzysztof Skrzętnicki
Hello Cafe,

I came up with (actually reinvented [1]) a solution to configuration
problem. For example configuration:

data Config = Config { port :: Int, verbosity :: Int, logfile :: FilePath }
deriving Show

the basic idea is to use implicit parameters:

runServer :: (?config :: Config) = IO ()

The problem is that it is tiresome to decorate all functions in this way.
It is also non composable. For example if we switch to using two separate
configuration entities like this:

data LogConfig = LogConfig { verbosity :: Int, logfile :: FilePath }
data NetConfig = NetConfig { port :: Int }

we suddenly have to fix types all over the place. Yuck.

The extended idea here (compared to [2]) is to use type synonym with all
required parameters. This is simple (but requires at least Rank2Types):

type ConfIO a = (?config :: Config) = IO a

All the functions requiring config will now be simply in ConfIO monad which
is really IO with a bonus. A great feature of this solution is that we
don't need to use liftIO anywhere.

The core *problem* with this approach is that at least current version of
GHC fails to propagate implicit parameters the way it propagate typeclass
requirements. For example I would like the following function to have
(inferred) type

-- printConfig :: (?config :: Config) = IO ()
printConfig = print (?config :: Config)

Instead GHC will complain about unbound implicit parameter. Similar problem
from GHCi session:

Prelude let f = print (?conf :: Int)
interactive:11:16:
Unbound implicit parameter (?conf::Int)
  arising from a use of implicit parameter `?conf'
In the first argument of `print', namely `(?conf :: Int)'
In the expression: print (?conf :: Int)
 In an equation for `f': f = print (?conf :: Int)

For reason I don't fully understand this is fixed by disabling monomorphic
restriction. The documentation mentions the problem but in a different
context:
http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#idp49108928

*TL;DR*: A nice solution to configuration problem is to use implicit
parameters and type synonym for IO monad extended with implicit
configuration parameters. It requires Rank2Types for defining the synonym
and NoMonomorphismRestriction for lightweight use.


Best regards,
Krzysztof Skrzętnicki


[1] I only realised this after starting the writing of this email. The
implicit parameters solution is given at least in [2]. Somehow I didn't
came across it before.
[2] Global Variables in Haskell
(2004)http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.23.145rep=rep1type=ps
by
John Hughes
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc-7 -fPIC error

2013-04-30 Thread Krzysztof Skrzętnicki
Hello,

please see this thread which I think is about the same issue you are
seeing: http://www.haskell.org/pipermail/haskell-cafe/2012-June/102023.html

In short, this is apparently caused by broken GCC. The solution is to
use build.mk with disable optimizations or download from
http://justhub.org/download which packages GHC for RHEL/CentOS/...

GhcLibWays = v
SRC_HC_OPTS= -H64m -O0 -fasm# -O -H64m
GhcStage1HcOpts= -O -fasm
GhcStage2HcOpts= -O0 -fasm  # -O2 -fasm
GhcLibHcOpts   = -O -fasm   # -O2 -XGenerics
GhcHcOpts  = -Rghc-timing
# GhcLibWays  += p
# GhcLibWays  += dyn
NoFibWays  =
STRIP_CMD  = :

Also cc-ing Chris Dornan of justhub.org.

Best regards,
Krzysztof Skrzętnicki


On Tue, Apr 30, 2013 at 4:05 AM, Christopher Howard
christopher.how...@frigidcode.com wrote:
 Hey guys, this probably isn't the official GHC mailing list, but I've
 been trying to build and install a new GHC on an old RHEL5 system, as
 mentioned in my previous Cafe thread. I was able to make some good
 headway: I installed a ghc-6.8 binary, and then used that to build
 ghc-6.10 source, and then used that to build ghc-6.12 source. The idea
 is to keep going until I get to ghc-7.6.

 However, when I get to 7.0, my builds all eventually die with this error:

 quote:
 
 /usr/bin/ld: rts/dist/build/RtsStartup.dyn_o: relocation R_X86_64_PC32
 against `StgRun' can not be used when making a shared object; recompile
 with -fPIC
 /usr/bin/ld: final link failed: Bad value
 collect2: ld returned 1 exit status
 

 After this failed the first time, I tried adding -fPIC to SRC_HC_OPTS,
 GhcStage1HcOpts, and so forth in build.mk. But ultimately I get the same
 error.

 I tried skipping a version and building ghc-7.2 instead, but the same
 error pops up.

 --
 frigidcode.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] how do i get cabal to reinstall dependencies with profiling enabled?

2013-04-18 Thread Krzysztof Skrzętnicki
Another option: use cabal-dev with --enable-library-profiling. It should do
the trick.

Best regards,
Krzysztof Skrzętnicki


On Wed, Apr 17, 2013 at 11:13 PM, Anatoly Yakovenko
aeyakove...@gmail.comwrote:



 ___
 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] GSoC Project Proposal: Markdown support for Haddock

2013-04-05 Thread Krzysztof Skrzętnicki
I think this thread has went to became a quest for One True Markup
Language...

I would like to propose a different approach: while we are at extending
Haddock why not make it possible to choose from a set of different
documentation plugins? Something that works akin to the type: Text -
Environment - Documentation, where Documentation is Haddock AST (possibly
extended)?

That would make most people happy and put the source code writer in power:
they could choose the syntax they would like to write their docs. Whether
it is Haddock markup, Github Markdown, RST or OneTrueMarkup (c) (r)
(patented).

The task of defining such an API could be actually harder than writing
support for any particular syntax but I think it is more beneficiary in the
long run.

*Bonus points:* provide the integration with .cabal files so that each
package can inform which plugins it expects.
*Extra bonus points:* let the plugin be simply the name of a function (or
datatype that implements a typeclass) which in turn would be taken from a
well-defined scope. (think: library that can provide its own plugin for
documenting itself).

Best regards,
Krzysztof Skrzętnicki


On Fri, Apr 5, 2013 at 4:24 AM, Richard A. O'Keefe o...@cs.otago.ac.nzwrote:


 On 5/04/2013, at 2:00 PM, Johan Tibell wrote:

  Would it be too much to ask that a notation be used which has
  a formal syntax and a formal semantics?
 
  We will document our superset, sure. That's what others did as well.
  The point is using Markdown as the shared base.

 Nononono.
 Sure, the others documented their supersets.
 But they did *NOT* provide what I am asking for:
  - a FORMAL SYNTAX and
  - a FORMAL SEMANTICS.
 I tried to use one of these systems, and found myself
 unable to determine which combinations of features were
 legal and what legal combinations of features *meant*.
 I corresponded with some people who had built markdown
 parsers, and the answer was the same each time: they had
 reversed engineered some other parser (typically a Perl
 one) and bashed on it until they were bug-compatible.

 If I want to get a particular effect in LaTeX or even in
 HTML+CSS, I can usually figure it out *without* having to
 run any program.  If I want to get a particular effect in
 Markdown, I flounder around and end up doing without.

 I am sick of documentation that vaguely hints at things,
 and I am especially sick of Markdown so-called documentation.

 To say it one more time:  I was unable to use the official
 Markdown documentation,
 http://daringfireball.net/projects/markdown/syntax,
 to guide the construction of a parser.

 For example, br is a valid URL enclosed in . . ., so
 is it a link, as the Automatic Links section would suggest,
 or is it embedded HTML, as the Inline HTML section would
 suggest?  Can you tell *from the documentation*?

 For another example, is *foo**bar**ugh* supposed to map to
 emfoostrongbar/strongugh/em or to
 emfoo/emembar/ememugh/em?
 Again, I'm not asking what does this or that *program* do,
 I'm asking can you tell from the documentation what they
 *ought* to do?

 If there is an unambiguous specification of Markdown somewhere
 (specification; not program), I would be glad to see it.



 ___
 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] Error when building executable with profiling enabled

2013-04-05 Thread Krzysztof Skrzętnicki
You are using TemplateHaskell (-fth switch) which can be tricky. Please see
this documentation on profiling with TH:
http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/template-haskell.html#id624714.
Other than following the documentation I would recommend using Cabal
which handles the necessary flags and double-compilation process itself.

Best regards,
Krzysztof Skrzętnicki


On Fri, Apr 5, 2013 at 4:41 PM, Nikolaos Bezirgiannis bez...@gmail.comwrote:


 Hello,

 i have an executable where i want to run profiling on.

 I do:

 ghc --make -prof -auto-all -fth Custom.hs

 but it does not built and the output is:

 bench\HLogo\Custom\Custom.hs:1:1:
 Dynamic linking required, but this is a non-standard build (eg. prof).
 You need to build the program twice: once the normal way, and then
 in the desired way using -osuf to set the object file suffix.

 I tried googling on the error with no success. What can I do to
 compile this file for profiling?

 Cheers,
 Nikos

 ___
 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] How to return a network connection to C

2013-02-28 Thread Krzysztof Skrzętnicki
If I understand you correctly you need a StablePtr to your Connection
value. Please see:
http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Foreign-StablePtr.html

Best regards,
Krzysztof Skrzętnicki


On Thu, Feb 28, 2013 at 6:31 PM, C K Kashyap ckkash...@gmail.com wrote:

 I am using http://hackage.haskell.org/package/connection.
 So I create network connection in Haskell

 getConnection :: IO Connection

 I'd like this connection to be returned to C so that subsequent calls from
 C can send in the connection handle.

 Regards,
 Kashyap


 On Thu, Feb 28, 2013 at 9:04 PM, Niklas Hambüchen m...@nh2.me wrote:

 What data type are you dealing with exactly?

 If you have a socket, I guess you can just use it from C (via FFI).

 PS:
 By Network.Connection, do you mean
 http://hackage.haskell.org/package/network-connection-0.1.1 ? Seems
 deprecated.

 On 28/02/13 06:14, C K Kashyap wrote:
  Hi,
  I am using Network.Connection to connect to gmail in my Haskell module -
  that's compiled to DLL and invoked from C.
 
  I need a mechanism to return the connection handle to C so that it can
  pass it in the subsequent calls. How can I achieve this?
 
  Regards,
  Kashyap
 
 
  ___
  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] FunPtr to C function with #arguments determined at runtime?

2013-02-17 Thread Krzysztof Skrzętnicki
Hi,

I think libffi might be the answer here. Please see Hackage and Haskell
wiki for details.

Cheers,
Krzysztof Skrzetnicki
17-02-2013 12:18, Ryan Newton rrnew...@gmail.com napisał(a):

 Hello cafe,

 I've been poking around and I haven't seen this addressed anywhere except
 obliquely in the end of section 8.5.1 of the report, where it says that
 variable argument C functions aren't supported:

http://www.haskell.org/onlinereport/haskell2010/haskellch8.html

 The scenario is pretty simple.  I generate C code at runtime.  I compile
 it to a .so.  I know how many arguments it expects (but only at runtime),
 and I get a FunPtr back from 'dlsym'.  How do I call it?

 I was hoping there would be some Raw lower level FFI layer that I could
 use to invoke a C function without automagic marshaling and all the other
 goodness provided by the normal foreign import mechanism.

 Failing that, will I just have to generate complex wrappers on the C side
 which I call N times to load up N arguments into some stateful container
 before finally launching the function?

 Thanks,
-Ryan



 ___
 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] ifdef based on which OS you're on

2013-02-15 Thread Krzysztof Skrzętnicki
Well, for sure you can in define that in .cabal file:

if !os(windows)
  CC-Options: -DWINDOWS

or something. See:
http://www.haskell.org/cabal/users-guide/developing-packages.html#configurations




On Fri, Feb 15, 2013 at 3:05 PM, Andrew Cowie 
and...@operationaldynamics.com wrote:

 I've got a piece of code that looks like this:

 baselineContextSSL :: IO SSLContext
 baselineContextSSL = do
 ctx - SSL.context
 SSL.contextSetDefaultCiphers ctx
 #if defined __MACOSX__
 SSL.contextSetVerificationMode ctx SSL.VerifyNone
 #elif defined __WIN32__
 SSL.contextSetVerificationMode ctx SSL.VerifyNone
 #else
 SSL.contextSetCADirectory ctx /etc/ssl/certs
 SSL.contextSetVerificationMode ctx $
 SSL.VerifyPeer True True Nothing
 #endif
 return ctx

 all very nice (this being necessary because apparently the non-free
 operating systems don't store their certs in a reliably discoverable
 place; bummer).

 That, however, is not the problem. After all, this sort of thing is what
 #ifdefs are for. The problem is needing to get an appropriate symbol
 based on what OS you're using defined.

 I naively assumed there would be __LINUX__ and __MACOSX__ and __WIN32__
 defined by GHC because, well, that's just the sort of wishful thinking
 that powers the universe.

 So my question is: what's an appropriate Haskell mechanism for building
 code that is OS / arch  / distro specific? It's not like I have autoconf
 running generating me a config.h I could #include, right?

 This feels simple and an appropriate use of CPP; even the symbol names
 look just about like what I would have expected; stackoverflow said so,
 must be true. Just need to get the right symbol defined at build time.

 Any suggestions?

 AfC
 Sydney


 ___
 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] Teaching haskell and fuzzy logic to high school students

2013-01-31 Thread Krzysztof Skrzętnicki
You can get the paper here for free:
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.40.1464



On Thu, Jan 31, 2013 at 12:02 PM, claudio wbig...@gmail.com wrote:

 I'm an Italian IT teacher and I would like to introduce functional
 programming using haskell.

 As classroom activity, I would like to build-up a simple fuzzy inference
 engine.

 Does anyone know if someone has experience in teaching haskell to high
 school students or something has already been done with fuzzy logic and
 haskell?

 I found only this page:
 http://www.haskell.org/haskellwiki/AI/Logic/Fuzzy
 with some information and a link to a pubblication (with fee, I didn't
 download yet).

 Thanks
 Claudio

 ___
 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] ANN: wizards-1.0: A High level, generic library for interrogative user interfaces

2012-07-01 Thread Krzysztof Skrzętnicki
Hello,

This library looks very nice. Thank you for realeasing it! I realise it
took quite an effort to write it.

Looking from examples on Github I noticed that you use
-XOverlappingInstances. Why do you need such extension?

Best regards,
Krzysztof Skrzętnicki

On Sun, Jul 1, 2012 at 10:17 AM, Liam O'Connor lia...@cse.unsw.edu.auwrote:

 Hi all,

 wizards is an Haskell library designed for the quick and painless
 development of interrogative programs, which revolve around a dialogue
 with the user, who is asked a series of questions in a sequence much like
 an installation wizard.

 Everything from interactive system scripts, to installation wizards, to
 full-blown shells can be implemented with the support of wizards.

 It is developed transparently on top of a free monad (see Swierstra's
 excellent paper on this topic at
 http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCarte.pdf),
 which separates out the semantics of the program from the wizards
 interface. A variety of backends exist, including a full featured backend
 for Haskeline, a debug-friendly simpler implementation in terms of
 System.IO primitives, and a completely pure implementation modelled as a
 function from an input string to output. It is also possible to write your
 own backends, or extend the existing back-ends with new features.

 While both built-in IO backends operate on a console, there is no reason
 why wizards cannot also be used for making GUI wizard interfaces.

 The library is highly extensible - back-ends can be written or extended
 with the type system helpfully tracking what features are supported by
 which back-ends.

 Installation instructions and some educational examples are at the github
 page:

 https://github.com/liamoc/wizards

 Information on how to write backends or extend backends, as well as
 structured API documentation is available on Hackage:

 http://hackage.haskell.org/package/wizards

 (Or, you can just run cabal haddock to generate the documentation from the
 source).

 Regards,
 Liam O'Connor


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

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


Re: [Haskell-cafe] Data.Bitmap, readBitmap exception

2012-06-28 Thread Krzysztof Skrzętnicki
That bitmap must be pretty weird. 'file' command reports 'data', so headers
must be off. Image viewer OTOH does handle the file.

Best regards,
Krzysztof Skrzętnicki

On Thu, Jun 28, 2012 at 2:03 PM, Brandon Allbery allber...@gmail.comwrote:

 On Thu, Jun 28, 2012 at 7:34 AM, Alexander Foremny 
 alexanderfore...@gmail.com wrote:

 I am using bitmap-0.2 [1] to load a Bitmap file [2]. However, the
 following sample GHCi session fails for me.


 For what it's worth, my system doesn't recognize your bitmap as a valid
 image file.

 --
 brandon s allbery  allber...@gmail.com
 wandering unix systems administrator (available) (412) 475-9364 vm/sms


 ___
 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] Hackage 2 maintainership

2012-06-19 Thread Krzysztof Skrzętnicki
Hi,

Are there any news how things are going? What remains there to be done to
get us to Hackage 2?

I found this list of tickets:
https://github.com/haskell/cabal/issues?labels=hackage2page=1state=open

Is there anything more to be done?

Best regards,
Krzysztof Skrzętnicki

On Tue, Feb 14, 2012 at 12:44 AM, Ben Gamari bgamari.f...@gmail.com wrote:

 Hey all,

 Those of you who follow the Haskell subreddit no doubt saw today's post
 regarding the status of Hackage 2. As has been said many times in the
 past, the primary blocker at this point to the adoption of Hackage 2
 appears to be the lack of an administrator.

 It seems to me this is a poor reason for this effort to be held
 up. Having taken a bit of time to consider, I would be willing to put in
 some effort to get things moving and would be willing to maintain the
 haskell.org Hackage 2.0 instance going forward if necessary.

 I currently have a running installation on my personal machine and
 things seem to be working as they should. On the whole, installation was
 quite trivial, so it seems likely that the project is indeed at a point
 where it can take real use (although a logout option in the web
 interface would make testing a bit easier).

 That being said, it would in my opinion be silly to proceed without
 fixing the Hackage trac. It was taken down earlier this year due to
 spamming[1] and it seems the recovery project has been orphaned. I would
 be willing to help with this effort, but it seems like the someone more
 familiar with the haskel.org infrastructure might be better equipped to
 handle the situation.

 It seems that this process will go something like this,
  1) Bring Hackage trac back from the dead
  2) Bring up a Hackage 2 instance along-side the existing
 hackage.haskell.org
  3) Enlist testers
  4) Let things simmer for a few weeks/months ensuring nothing explodes
  5) After it's agreed that things are stable, eventually swap the
 Hackage 1 and 2 instances

 This will surely be a non-trivial process but I would be willing to move
 things forward.

 Cheers,

 - Ben


 [1] http://www.haskell.org/pipermail/cabal-devel/2012-January/008427.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] [Haskell] JustHub 'Sherkin' Release

2012-06-15 Thread Krzysztof Skrzętnicki
To be honest I did try to use Nix for exactly this purpose. For some reason
things started to break and since I couldnt find any documentation on how
to do stuff with it, I just abandonded the idea. Also tried out NixOS:
pretty much the same story. Everything appears to be fine at the start, but
then after few upgrades things start to fail.

I know its very vague but really this is how I remember this experience.
For one thing there was lack of how tos related to Haskell stuff
anywhere. Just some general documentation that really have some gaps. You
end up digging up some implementation details just because you wanted to
install a new package.

I'm not trying to spread FUD: only telling my not-so-success story with Nix.

I'm sure Nix/NixOS has some potential but clearly it's not there yet for
some reason.

Best regards,
Krzysztof Skrzętnicki

On Fri, Jun 15, 2012 at 9:10 PM, Peter Simons sim...@cryp.to wrote:

 Hi Chris,

   I cannot see how it can address any of the user-level Haskell package
   database management and sandboxing mechanisms that I mentioned in the
   announcement and subsequent emails.

 have you ever actually used Nix?

 Take care,
 Peter


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

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


Re: [Haskell-cafe] Data.Bitmap question

2012-06-07 Thread Krzysztof Skrzętnicki
There is module with a set of unsafeFoo functions here:
http://hackage.haskell.org/packages/archive/bitmap/0.0.2/doc/html/Data-Bitmap-Pure-Pixels.html

I guess you can use them, but I haven't personally used it.

I have, with great success, used different package: JuicyPixels (here:
http://hackage.haskell.org/package/JuicyPixels).

Best regards,
Krzysztof Skrzętnicki

On Thu, Jun 7, 2012 at 2:59 PM, Anders Lyckegaard 
anders.lyckega...@gmail.com wrote:

 Hi,

 I have a short question on using Data.Bitmap.

 I have imported an image using STB-image.

 img - loadImage filename

 Now I get img which is a Bitmap data structure. How do I access individual
 pixels?

 Thank you in advance,
 Anders

 ___
 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] Google Summer of Code - Lock-free data

2012-03-30 Thread Krzysztof Skrzętnicki
Hi,

I was interested in Distruptor few months ago and started to write a
Haskell implementation. Soon I discovered the lack of native CAS operations
and abandoned project for a while. I don't really have time to develop it
further right now, but the code is available:
https://github.com/Tener/disruptor-hs

The code as it is now is mostly benchmarking code. I think it is worth
trying out.

You mention benchmarking TChans: one particular problem with TChans and
Chans is that they are unbounded. If the producers outpace consumers it
soon ends with memory exhaustion.

In the process of writing above code I discovered particularly simple data
structure that performs suprisingly well (full implementation:
https://github.com/Tener/disruptor-hs/blob/master/Test/ManyQueue.hs) :

type Queue a = [MVar a]
mkQueue size = cycle `fmap` (replicateM size newEmptyMVar)


The throutput is very high, it is bounded and scales well with the number
of producer/consumers threads. In the presence of multiple
consumers/producers it's not a FIFO queue though, but rather a kind of
buffer with funny ordering.

Best regards,
Krzysztof Skrzętnicki

On Fri, Mar 30, 2012 at 00:03, John Lato jwl...@gmail.com wrote:

 Slightly related: I think it would be interesting to compare a
 Disruptor-based concurrency communications mechanism and compare it to
 e.g. TChans

 1.  Disruptor - http://code.google.com/p/disruptor/

  From: Ryan Newton rrnew...@gmail.com
 
  I think so. Atomically reading and writing a single memory location
  (which CAS does) is just a very simple transaction. But using a CAS
  instruction should be more efficient, since STM has to maintain a
  transaction log and commit transactions, which creates some overhead.
 
 
  Ah, I see. In that case, it may be worthwhile to implement the CAS
  instruction in terms of STM as well and measure the performance
 difference
  this makes for the final data structure. After all, STM is a lot more
  compositional than CAS, so I'd like to know whether the loss of
  expressiveness is worth the gain in performance.
 
 
  There's one annoying hitch with doing apples-to-apples comparisons here.
 
  The problem is that CAS falls short of being a hardware-accelerated
 version
  of a simple transaction (read TVar, (==) against expected value,
  conditionally update TVar), because CAS is based on pointer equality
 rather
  than true equality.  (eq? rather than equal? for any Schemers out there.)
 
  For this reason our Fake version of CAS -- for older GHCs and for
  performance comparison -- has to use reallyUnsafePointerEquality#:
 
 
 
 http://hackage.haskell.org/packages/archive/IORefCAS/0.2/doc/html/Data-CAS-Internal-Fake.html
 
  But we do provide a CASable type class in that package which is
 precisely
  for comparing the performance of:
 
- Hardware CAS
- Fake CAS -- atomicModifyIORef + ptrEquality
- Foreign CAS -- gcc intrinsic + function call

 ___
 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] Increase GHC stack size?

2012-02-05 Thread Krzysztof Skrzętnicki
No, you supply -rtsopts along with --make. Actually --make is just a
shorthand for a few other options, you can see which with --verbose. See
the documentation too.

One important thing though: very often stack overflows come from bad code.
See the wiki for more info:
http://www.haskell.org/haskellwiki/Stack_overflow

Best regards,
Krzysztof Skrzętnicki

On Sun, Feb 5, 2012 at 20:50, Michael Rice limitc...@gmail.com wrote:

 I'm using
 ghc --make...

 -rtsopts seems to be a link directive.

 The GHC docs seem to be project oriented. What's the two step process to
 compile and link a simple .hs file?

 ghc source.hs (to compile)

 link step?

 Michael





 On Sun, Feb 5, 2012 at 2:21 PM, Mathijs Kwik math...@bluescreen303.nlwrote:

 ./myProgram +RTS -K1600

 If that gives an error, you're program was probably compiled without
 support for setting RTS options from the command line.
 Recompile with -rtsopts.
 Then the above should work



 On Sun, Feb 5, 2012 at 8:16 PM, Michael Rice limitc...@gmail.com wrote:
  Stack space overflow: current size 8388608 bytes.
  Use `+RTS -Ksize -RTS' to increase it.
 
  ==
 
  Couldn't find much on the man or info pages. Example please, say double
 it
  (1600) for starters.
 
  Michael
 
 
  ___
  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] Serialize instance for System.Posix.Files.FileStatus

2012-02-01 Thread Krzysztof Skrzętnicki
I assume you speak about Serialize typeclass from cereal package and
FileStatus from unix package.

There are several problems with implementing such instance:

- FileStatus doesn't export the fact it's a newtype around Ptr CStat
- CStat isn't exported either
- there are no constructors for  FileStatus  or any way to change the value
of it
- it could be implemented internally in unix but then it would have to
depend on cereal which is non-trivial change

So implementing such instance would basically mean heavy changes to unix
package.

My advice: implement your own datatype with information equivalent to
FileStatus, say FileStatusData, along with function mkFileStatusData ::
FileStatus - FileStatusData and provide instance for Serialize for
FileStatusData.

As for efficiency: I'm not sure it can be done in any better way. In
particular you can't be sure that on the system on which you are going to
deserialize the value the CStat structure has the same memory layout. So
you have to use proper serialization on Haskell side to achieve correctness.

Best regards,
Krzysztof Skrzętnicki

On Wed, Feb 1, 2012 at 15:02, Johan Brinch brin...@gmail.com wrote:

 Are there plans on implementing an efficient Serialize instance of the
 FileStatus type?

 I'm aware that it's just a wrapper around a C stat structure, and I
 reckon it can be done more efficiently than copying from C to Haskell
 for every value.

 --
 Johan Brinch

 ___
 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] Efficient temporary file storage??

2012-01-23 Thread Krzysztof Skrzętnicki
From my experience I can recommend msgpack (
http://hackage.haskell.org/package/msgpack) as being extremely fast. It
comes with optimized prepared instances for common data structures which is
very nice, because you don't have to roll your own version with library
like cereal (which is indeed very fast, but simply less convenient).

Best regards,
Krzysztof Skrzętnicki

On Tue, Jan 24, 2012 at 00:37, Nick Rudnick nick.rudn...@googlemail.comwrote:

 Dear all,

 if you want to temporarily store haskell data in a file – do you have a
 special way to get it done efficiently?

 In an offline, standalone app, I am continuously reusing data volumes of
 about 200MB, representing Map like tables of a rather simple structure,

 key: (Int,Int,Int)
 value: [((Int,Int),LinkId)]


 which take quite a good deal of time to produce.

 Is there a recommendation about how to 'park' such data tables most
 efficiently in files – any format acceptable, quick loading time is the
 most desirable thing.

 Thanks a lot in advance, Nick

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


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


Re: [Haskell-cafe] Poll: Do you want a mascot? -- please stop this

2011-11-23 Thread Krzysztof Skrzętnicki
I second this.

One way is to use Forms from Google Docs.

1. They have been used with success before for similar pools
2. Can provide more elaborate questions
3. Automatically put results into a spreadsheet, which is useful
4. Protect against double-voters (sort of)
5. No spam

Best regards,
Krzysztof Skrzętnicki

On Wed, Nov 23, 2011 at 21:25, Giovanni Tirloni gtirl...@sysdroid.comwrote:

 On Wed, Nov 23, 2011 at 5:52 PM, heathmatlock heathmatl...@gmail.comwrote:

 On Wed, Nov 23, 2011 at 1:40 PM, Alexander Bernauer 
 alex-hask...@copton.net wrote:

 Yes

 PS: Why not using Doodle for the poll?


 Email is an easy way to make sure nobody votes twice.


 1. It's unlikely to get feedback from the larger Haskell community
 2. It floods people with email they don't care (unless they care to keep
 track of the results)
 3. One can just as easily create throw-away emails, subscribe to the list
 and answer the poll
 4. etc...

 My suggestion is to create a poll somewhere else and let it run for at
 least a month.

 Or a more elaborated survey with additional questions trying to capture
 the community's feeling toward a masket and what kind.

 I don't think we are in a hurry to get a mascot here so let's take the
 time and do it properly.

 --
 Giovanni



 ___
 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] Yesod 0.7.1 using GHC 7.0.2 on Arch Linux

2011-03-13 Thread Krzysztof Skrzętnicki
You can also download binary tarball, untar, ./configure
--prefix=$HOME/ghc-7.0.2, make install, export PATH=$PATH:$HOME/ghc-7.0.2
and you will be good to go.

Best regards,
Krzysztof Skrzętnicki

On Mon, Mar 14, 2011 at 02:15, Ertugrul Soeylemez e...@ertes.de wrote:

 I know, but at least I can go on with development.  I hope, the problem
 will be fixed soon.


 vagif.ve...@gmail.com wrote:

  No, it is not solved.
  With -fproduction flag you are loosing devel-server functionality.
 
  On Saturday, March 12, 2011 02:45:11 PM Ertugrul Soeylemez wrote:
   Oh, I just noticed the other thread about this issue.  Compiling Yesod
   with the -fproduction flag solved it.
  
   Thanks to Michael for that.
  
  
   Greets,
   Ertugrul
  
   Ertugrul Soeylemez e...@ertes.de wrote:
Hello Ryan,
   
thanks a lot.
   
Is there a workaround for this, until it's fixed?
   
   
Greets,
Ertugrul
   
Ryan Yates fryguy...@gmail.com wrote:
 Looks to be reported here:

 http://hackage.haskell.org/trac/ghc/ticket/5004


 http://hackage.haskell.org/trac/ghc/ticket/5004Ryan

 On Sat, Mar 12, 2011 at 3:26 PM, Ertugrul Soeylemez e...@ertes.de
 wrote:
  Hello there,
 
  today I have upgraded to GHC 7.0.2 by doing a system update on my
  Arch Linux box (x86, 32 bits), and I'm having difficulties to
  install Yesod. Its dependencies seem to have been installed
 without
  problems, but the
 
  Yesod package itself fails.  The complete build log follows:
 % cabal install yesod
 Resolving dependencies...
 Configuring yesod-0.7.1...
 Preprocessing library yesod-0.7.1...
 Preprocessing executables for yesod-0.7.1...
 Building yesod-0.7.1...
 [1 of 1] Compiling Yesod( Yesod.hs,
 dist/build/Yesod.o
 ) Registering yesod-0.7.1...
 [1 of 2] Compiling CodeGen  ( CodeGen.hs,
 
  dist/build/yesod/yesod-tmp/CodeGen.o )
 
 [2 of 2] Compiling Main ( scaffold.hs,
 
  dist/build/yesod/yesod-tmp/Main.o )
 
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Loading package bytestring-0.9.1.10 ... linking ... done.
 Loading package base64-bytestring-0.1.0.2 ... linking ...
 done.
 Loading package array-0.3.0.2 ... linking ... done.
 Loading package containers-0.4.0.0 ... linking ... done.
 Loading package cereal-0.3.0.0 ... linking ... done.
 Loading package filepath-1.2.0.0 ... linking ... done.
 Loading package old-locale-1.0.0.2 ... linking ... done.
 Loading package old-time-1.0.0.6 ... linking ... done.
 Loading package unix-2.4.2.0 ... linking ... done.
 Loading package directory-1.1.0.0 ... linking ... done.
 Loading package binary-0.5.0.2 ... linking ... done.
 Loading package data-default-0.2.0.1 ... linking ... done.
 Loading package tagged-0.2 ... linking ... done.
 Loading package crypto-api-0.5.2 ... linking ... done.
 Loading package pureMD5-2.1.0.3 ... linking ... done.
 Loading package pretty-1.0.1.2 ... linking ... done.
 Loading package template-haskell ... linking ... done.
 Loading package transformers-0.2.2.0 ... linking ... done.
 Loading package deepseq-1.1.0.2 ... linking ... done.
 Loading package text-0.11.0.5 ... linking ... done.
 Loading package blaze-builder-0.2.1.4 ... linking ... done.
 Loading package blaze-html-0.4.1.0 ... linking ... done.
 Loading package file-embed-0.0.3.1 ... linking ... done.
 Loading package time-1.2.0.3 ... linking ... done.
 Loading package unix-compat-0.2.1.1 ... linking ... done.
 Loading package enumerator-0.4.7 ... linking ... done.
 Loading package mtl-2.0.1.0 ... linking ... done.
 Loading package parsec-3.1.1 ... linking ... done.
 Loading package network-2.2.1.10 ... linking ... done.
 Loading package wai-0.3.2 ... linking ... done.
 Loading package utf8-string-0.3.6 ... linking ... done.
 Loading package web-routes-0.23.4 ... linking ... done.
 Loading package wai-app-static-0.0.1.1 ... linking ... done.
 Loading package random-1.0.0.3 ... linking ... done.
 Loading package clientsession-0.4.1 ... linking ... done.
 Loading package cookie-0.0.0 ... linking ... done.
 Loading package failure-0.1.0.1 ... linking ... done.
 Loading package extensible-exceptions-0.1.1.2 ... linking ...
 done. Loading package QuickCheck-2.4.0.1 ... linking ... done.
 Loading package blaze-builder-enumerator-0.2.0.1 ... linking
 ...
 done. Loading package json-types-0.1 ... linking ... done.
 Loading package json-enumerator-0.0.1 ... linking

[Haskell-cafe] Possible bug in Control.Concurrent

2011-02-09 Thread Krzysztof Skrzętnicki
Hello Cafe,

Here is a simple program that yields strange results:

module Main where

import Control.Concurrent
import Control.Concurrent.Chan
import Control.Monad

main = do
 c - newChan
 writeChan c 1
 forkIO $ forever $ do
   i - readChan c
   print (forkio,i)
isEmptyChan c = print

First of all, if we try to run it via runhaskell, it will hang:

runhaskell deadlock.hs
(forkio,1)
-- no more output --


Compiled version OTOH behaves differently dependent on compilation flags.
Without -threaded:
./deadlock
(forkio,1)
False

With -threaded:
./deadlock
False

Now, this is strange thing: we put single element into the channel. We take
it out. And then we see the channel isn't really empty. Perhaps there is a
race condition here? So we put an delay, so that we will be sure the check
for empty channel occurs 1 second later than the channel is emptied.

import Control.Concurrent
import Control.Concurrent.Chan
import Control.Monad

main = do
 c - newChan
 writeChan c 1
 forkIO $ forever $ do
   i - readChan c
   print (forkio,i)
  threadDelay 100
 isEmptyChan c = print

This program will misbehave. Invariably of -threaded flag it will go like
this:

./deadlock
(forkio,1)
deadlock: thread blocked indefinitely in an MVar operation

I have no idea what is the problem here. Perhaps I'm not using the library
in the right way. Does anyone has any idea what's going on here?

Best regards,
Krzysztof Skrzętnicki
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Possible bug in Control.Concurrent

2011-02-09 Thread Krzysztof Skrzętnicki
Shame on me, I forgot to include the software versions I use:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.3

$ uname -a
Linux raptor 2.6.37-ARCH #1 SMP PREEMPT Sat Jan 29 20:00:33 CET 2011 x86_64
Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz GenuineIntel GNU/Linux

This is a normal Arch Linux setup with GHC installed via pacman.

Best regards,
Krzysztof Skrzętnicki

2011/2/9 Krzysztof Skrzętnicki gte...@gmail.com

 Hello Cafe,

 Here is a simple program that yields strange results:

 module Main where

 import Control.Concurrent
 import Control.Concurrent.Chan
 import Control.Monad

 main = do
  c - newChan
  writeChan c 1
  forkIO $ forever $ do
i - readChan c
print (forkio,i)
 isEmptyChan c = print

 First of all, if we try to run it via runhaskell, it will hang:

 runhaskell deadlock.hs
 (forkio,1)
 -- no more output --


 Compiled version OTOH behaves differently dependent on compilation flags.
 Without -threaded:
 ./deadlock
 (forkio,1)
 False

 With -threaded:
 ./deadlock
 False

 Now, this is strange thing: we put single element into the channel. We take
 it out. And then we see the channel isn't really empty. Perhaps there is a
 race condition here? So we put an delay, so that we will be sure the check
 for empty channel occurs 1 second later than the channel is emptied.

 import Control.Concurrent
 import Control.Concurrent.Chan
 import Control.Monad

 main = do
  c - newChan
  writeChan c 1
  forkIO $ forever $ do
i - readChan c
print (forkio,i)
   threadDelay 100
  isEmptyChan c = print

 This program will misbehave. Invariably of -threaded flag it will go like
 this:

 ./deadlock
 (forkio,1)
 deadlock: thread blocked indefinitely in an MVar operation

 I have no idea what is the problem here. Perhaps I'm not using the library
 in the right way. Does anyone has any idea what's going on here?

 Best regards,
 Krzysztof Skrzętnicki

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


Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC

2011-02-03 Thread Krzysztof Skrzętnicki
One thing to notice:
$ cabal install network-server

is needed.

Best regards,
Krzysztof Skrzętnicki

On Thu, Feb 3, 2011 at 12:15, C K Kashyap ckkash...@gmail.com wrote:

 Hi,
 I've been working on a Haskell based platform independent graphics
 rendering
 using VNC. I'd like it very much if you could take a look at it and give me
 feedback. Using it is straight forward -

 git clone g...@github.com:ckkashyap/Chitra.git
 cd Chitra
 make
 ./Main 100 100 5900

 Main starts off a vncserver listening on port 5900. A standard vncviewer
 can be
 used to connect to 'localhost' and you can see a 100 x 100 screen. Clicking
 on
 the screen will set the pixel on the click location.

 What I eventually want to do is somehow integrate this piece with GHCI in
 such
 a manner that one can use GHCI to draw things on the VNC buffer.

 Regards,
 Kashyap


 ___
 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] Packages all screwed up

2011-02-01 Thread Krzysztof Skrzętnicki
This is the easiest way conceptually. You can also try to --reinstall every
package that 'ghc-pkg check' report is broken. If you pick up the right
version and compilation options will match there is a high chance you can
fix this state. I've done this before and it worked.

Best regards,
Krzysztof Skrzętnicki

On Tue, Feb 1, 2011 at 08:16, Arnaud Bailly arnaud.oq...@gmail.com wrote:

 Hi,
 Thanks for your answers.

 I did

  cabal upgrade yesod

 As for the user/global issue, I think I tried a user install, this is
 default isn't it?

 Looks like I will have to reinstall everything :-(

 Arnaud

 On Tue, Feb 1, 2011 at 1:34 AM, Antoine Latter aslat...@gmail.com wrote:
  On Mon, Jan 31, 2011 at 4:59 PM, Arnaud Bailly arnaud.oq...@gmail.com
 wrote:
  Hello,
  I recently tried to upgrade some package (eg. yesod) and it seems
  that, in the process, I screwed up my Haskell packages setup.
  When I am trying to do a simple:
  ghc --make Crete1941
 
  What command(s) did you issue to upgrade some packages?
  Were you trying to do a user or global install?
 
  When ghc loads packages, I've had cases where packages in the user db
  would shadow packages in the global db, causing *other* packages in
  the global db to report as broken.
 
  Thanks,
  Antoine
 

 ___
 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] Packages all screwed up

2011-02-01 Thread Krzysztof Skrzętnicki
AFAIK GHC on Windows comes with it's own mingw, but I'm not sure if the
toolchain is complete. But I wouldn't try to reinstall core packages anyway.
They are best picked from installation package.

Best regards,
Krzysztof Skrzętnicki

2011/2/1 Arnaud Bailly arnaud.oq...@gmail.com

 I started that way but quickly ran into issues about compilers
 toolchain for certain packages: I am on windows and some core packages
 require mingw toolchain.


 2011/2/1 Krzysztof Skrzętnicki gte...@gmail.com:
  This is the easiest way conceptually. You can also try to --reinstall
 every
  package that 'ghc-pkg check' report is broken. If you pick up the right
  version and compilation options will match there is a high chance you can
  fix this state. I've done this before and it worked.
  Best regards,
  Krzysztof Skrzętnicki
 
  On Tue, Feb 1, 2011 at 08:16, Arnaud Bailly arnaud.oq...@gmail.com
 wrote:
 
  Hi,
  Thanks for your answers.
 
  I did
 
   cabal upgrade yesod
 
  As for the user/global issue, I think I tried a user install, this is
  default isn't it?
 
  Looks like I will have to reinstall everything :-(
 
  Arnaud
 
  On Tue, Feb 1, 2011 at 1:34 AM, Antoine Latter aslat...@gmail.com
 wrote:
   On Mon, Jan 31, 2011 at 4:59 PM, Arnaud Bailly 
 arnaud.oq...@gmail.com
   wrote:
   Hello,
   I recently tried to upgrade some package (eg. yesod) and it seems
   that, in the process, I screwed up my Haskell packages setup.
   When I am trying to do a simple:
   ghc --make Crete1941
  
   What command(s) did you issue to upgrade some packages?
   Were you trying to do a user or global install?
  
   When ghc loads packages, I've had cases where packages in the user db
   would shadow packages in the global db, causing *other* packages in
   the global db to report as broken.
  
   Thanks,
   Antoine
  
 
  ___
  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] Behaviour of System.Directory.getModificationTime

2010-12-16 Thread Krzysztof Skrzętnicki
If this is not a toy program I would really suggest using something that is
builtin in the OS of choice. On Linux there is inotify (
http://en.wikipedia.org/wiki/Inotify), but I'm pretty sure that other OSes
have similar interfaces. The modification time method seems really fragile
and I probably not very efficient as well.

Best regards,
Krzysztof Skrzętnicki

On Thu, Dec 16, 2010 at 17:50, Arnaud Bailly arnaud.oq...@gmail.com wrote:

 actually, IRL the code works as expected. Might it be possible that
 the speed of test execution is greater than the granularity of the
 system's modification timestamp?

 ___
 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] ANN: mute-unmute-0.2.0.0

2010-08-27 Thread Krzysztof Skrzętnicki
*
Hello!

I'm pleased to announce a small utility program I wrote recently. Today I
pushed version 0.2.0.0 of mute-unmute to Hackage, from with you can
cabal-install it right now (following the usual 'update' step). What it
does? It's simple: it will mute the sound when you lock your screen and
unmute it back again when you unlock it.

Why anyone would need such program? Well, this is a little bit
more complicated.

I work in open space kind of office. It can get quite noisy there. I often
sit with headphones on, but when I walk away from my desk I put them down
and lock my screen. Here comes uncomfortable moment: when I remove my
headphones suddenly people around me who doesn't use their headphones now
start to hear the music I listen to. And they don't always like it, so I
manually mute the sound to make happy.

But now, instead of doing this task by hand I have a program do it for me
:-)

Unfortunately this kind of programs tend to be pretty much platform
specific. Current version supports the recent versions of Gnome and KDE, but
needs ALSA. It's quite common setup, but if you happen to have a different
one you can easily hack the code (it's very straightforward) and send me
patches. Patches are always welcome. The source repo is on Github and
released versions are on Hackage:

Github:
 http://github.com/Tener/mute-unmute http://github.com/Tener/mute-unmute#
Hackage:
http://hackage.haskell.org/package/mute-unmute

Example use:

~/ mute-unmute # first session, it will ask for configuration options
mute-unmute: Creating config directory...
mute-unmute: Mute config is missing...
Mute sound card and press RETURN

mute-unmute: Unmute config is missing...
Unmute sound card and press RETURN

mute-unmute: Session: UnixAbstract {addrPath = /tmp/dbus-1tB1AEUcgg,
addrGuid = Just 19ec85e3778816ad38a77bbf003f}
mute-unmute: Connected
mute-unmute: Handler added: [MatchType Signal,MatchInterface
org.gnome.ScreenSaver,MatchMember ActiveChanged,MatchPath
/org/gnome/ScreenSaver]
mute-unmute: Handler added: [MatchType Signal,MatchInterface
org.freedesktop.ScreenSaver,MatchMember ActiveChanged,MatchPath
/ScreenSaver]
^C

~/ mute-unmute # remembers previous options which can be changed by calling
with --store switch
mute-unmute: Session: UnixAbstract {addrPath = /tmp/dbus-1tB1AEUcgg,
addrGuid = Just 19ec85e3778816ad38a77bbf003f}
mute-unmute: Connected
mute-unmute: Handler added: [MatchType Signal,MatchInterface
org.gnome.ScreenSaver,MatchMember ActiveChanged,MatchPath
/org/gnome/ScreenSaver]
mute-unmute: Handler added: [MatchType Signal,MatchInterface
org.freedesktop.ScreenSaver,MatchMember ActiveChanged,MatchPath
/ScreenSaver]
mute-unmute: Message {mType = Signal, mFlags = [NoReplyExpected], mSerial =
31, mPath = Just /org/gnome/ScreenSaver, mInterface = Just
org.gnome.ScreenSaver, mMember = Just ActiveChanged, mErrorName =
Nothing, mReplySerial = Nothing, mDestination = Nothing, mSender = Just
:1.19, mBody = [Variant (True) {- b -}]}
mute-unmute: Lock screen
mute-unmute: Message {mType = Signal, mFlags = [NoReplyExpected], mSerial =
32, mPath = Just /org/gnome/ScreenSaver, mInterface = Just
org.gnome.ScreenSaver, mMember = Just ActiveChanged, mErrorName =
Nothing, mReplySerial = Nothing, mDestination = Nothing, mSender = Just
:1.19, mBody = [Variant (False) {- b -}]}
mute-unmute: Unlock screen
^C


*
You can get usage information with --help switch:

*~/ mute-unmute --help
*mute-unmute
 --store ask for mute and unmute configurations
 --store-muteask for mute configuration
 --store-unmute  ask for unmute configuration
 -d  --daemonwait for screensaver state changes
 -h, -?  --help  show help

There isn't much more I can say. I hope you find the program at least
educational (as a simple example of DBus usage) if not useful.

Best regards,
Krzysztof Skrzętnicki
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Installing encoding package from Hackage

2010-01-24 Thread Krzysztof Skrzętnicki
I was able to build encoding-0.6.2. My steps:

(0. Update package list with 'cabal update')
1. Unpack package with 'cabal unpack encoding'
2. Edit encoding.cabal. We need to add HaXml as dependency. It should
be added to 'Build-Depends' field. I've added below HaXml == 1.20.2
because 1.20.2. is the latest version available at the time of
writing.

Library
  if flag(splitBase)
if flag(newGHC)
  Build-Depends:bytestring, base = 3   5, binary, mtl,
containers, extensible-exceptions, array, template-haskell,
regex-compat, ghc-prim, ghc = 6.10, HaXml == 1.20.2
else
  Build-Depends:bytestring, base = 3   5, binary, mtl,
containers, extensible-exceptions, array, template-haskell,
regex-compat, ghc  6.10, HaXml == 1.20.2
  else
Build-Depends:  base  3, binary, extensible-exceptions, 
template-haskell

3. Instal with cabal install run in the directory next to encoding.cabal.


It looks like package maintainer forgot to specify this dependency.

Best regards

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


[Haskell-cafe] ANN: readline-statevar-1.0.1.0

2009-12-05 Thread Krzysztof Skrzętnicki
Hello

I am happy to announce a release of small package called readline-statevar.
It's a small wrapping library around readline, which in turn wraps
libreadline. The reason I wrote it is because I wasn't happy with the API of
readline. It was composed of tons of functions like setX/getX, where there
could be just one StateVar instead, yielding OpenGL-kind API.

This version aims to match readline-1.0.1.0. (Hence the version number
chosen). I wrote it mostly manually, with a little help from my emacs-fu, so
there is a chance I missed a thing or two.

There is git repo available [1], along with issue tracker [2] and Hackage
page [3]. Feel encouraged to:
 cabal update
 cabal install readline-statevar
And give it a try!

Best regards

Krzysztof Skrzętnicki

[1] http://github.com/Tener/haskell-readline-statevar/
[2] http://github.com/Tener/haskell-readline-statevar/issues
[3] http://hackage.haskell.org/package/readline-statevar
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: package-vt-0.1.3.3, Haskell Package Versioning Tool

2009-11-26 Thread Krzysztof Skrzętnicki
Hi!

I'm pleased to announce the first release of my program package-vt. It's
role is to detect changes between two versions of package that should cause
version bump.

Recommended versioning policy for Haskell packages is on the wiki [1].

The ultimate goal is to get as good approximation of the algorithm specified
there as possible. Currently the tool is far from being complete: it only
detects changes to exports in .cabal and module files, but doesn't take any
types into consideration, not to mention other possible heuristics.

This tool is not meant as a replacement for developer's own brain. It can
only detect a subset of changes, and there will always be some important
changes it won't catch, like adding such line:
head (_:y:_) = y

However, it can be used for some quality checks.

Thing that needs improving is user interface. No options are currently
accepted. This, and a lot more, will change in future versions.

You can find a Git repo here [2]. The repo contains 'tests' directory with
two useful scripts. You can use them to run package-vt on anything from
Hackage.
Here are a few random usage examples:

1) Detect small change within module

package-vt packages/HCL/1.1/HCL-1.1/HCL.cabal
packages/HCL/1.2/HCL-1.2/HCL.cabal
Single changes:
ChangeABC : Entity added to module ModuleName HCL
---
EVar (UnQual (Ident prompt1))


---
Biggest change comes from:
ChangeABC : Entity added to module ModuleName HCL
---
EVar (UnQual (Ident prompt1))

2) Detect new module added to .cabal

package-vt 0.2.0/AERN-Net-0.2.0/AERN-Net.cabal
0.2.1/AERN-Net-0.2.1/AERN-Net.cabal
Single changes:
ChangeABC : Entity added to module ModuleName
Control.ERNet.Foundations.Process
---
EThingAll (UnQual (Ident ERProcessAction))


---ChangeABC : Module(s) added.(Consider AB change if new modules are likely
to cause name collisions)
---
Control/ERNet/Blocks/Real/LFT


---
Biggest change comes from:
ChangeABC : Module(s) added.(Consider AB change if new modules are likely to
cause name collisions)
---
Control/ERNet/Blocks/Real/LFT


---

3) Using testing script: package-vt correctly detects that AERN-RnToRM-0.4.9
should rather be 0.5.0 because the module
Data.Number.ER.RnToRm.UnitDom.ChebyshevBase.Polynom.Field
has been removed.

./test-on-package.lhs AERN-RnToRm
--cut--
 Testing package-vt on AERN-RnToRm-0.4.2 and AERN-RnToRm-0.4.9
Parse error: VarSym # : SrcLoc {srcFilename =
0.4.2/AERN-RnToRm-0.4.2/src/Data/Number/ER/RnToRm/Approx/DomTransl.hs,
srcLine = 174, srcColumn = 1}
Single changes:
ChangeABC : Entity added to module ModuleName Data.Number.ER.RnToRm.Approx
---
EVar (UnQual (Ident keyPointsConsistencyCheck))
EVar (UnQual (Ident keyPointsPointwiseConsistencyCheck))


---ChangeABC : Entity added to module ModuleName
Data.Number.ER.RnToRm.UnitDom.Approx
---
EVar (UnQual (Ident keyPointsConsistencyCheck))
EVar (UnQual (Ident keyPointsPointwiseConsistencyCheck))


---ChangeAB : Module(s) removed/renamed.
---
Data/Number/ER/RnToRm/UnitDom/ChebyshevBase/Polynom/Field


---
Biggest change comes from:
ChangeAB : Module(s) removed/renamed.
---
Data/Number/ER/RnToRm/UnitDom/ChebyshevBase/Polynom/Field


---
ExitSuccess

--cut--

In case of any trouble please email me or report an issue here [3].
In the near future I'll post more specific plans about development on my
blog [4].

I hope you will find it useful.

Best regards,

Krzysztof Skrzętnicki

[1] http://www.haskell.org/haskellwiki/Package_versioning_policy
[2] http://github.com/Tener/haskell-package-vt
[3] http://github.com/Tener/haskell-package-vt/issues
[4] http://mostlycode.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Installing documentation with cabal

2009-08-18 Thread Krzysztof Skrzętnicki
It is. From command line:

cabal install package --enable-documentation

or add line
documentation: True
to .cabal/config or equivalent.

Best regards

Krzysztof Skrzętnicki


On Tue, Aug 18, 2009 at 22:29, Maciej Piechotka uzytkown...@gmail.comwrote:

 Is it possible to automatically (or non-automatically) install
 documentation when installing package with cabal-install?

 Regards

 ___
 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] How to know the build dependencies?

2009-06-14 Thread Krzysztof Skrzętnicki
If your module compiles, you can get the info by passing '-ddump-types':

TYPE SIGNATURES
numbersTests :: Test
testAverage :: Test
testBindInt :: Test
TYPE CONSTRUCTORS
Dependent modules: [(MoresmauJP.Util.Numbers, False)]
Dependent packages: [HUnit-1.2.0.3, base, ghc-prim, integer]

It is, however, available only after your code has successfully compiled.

Best regards

Krzysztof Skrzętnicki

On Sun, Jun 14, 2009 at 04:22, Magicloud
Magicloudsmagicloud.magiclo...@gmail.com wrote:
 Hi,
  I am learning to use cabal for my code.
  Just when I start, I met a question, is there an easy way to find
 out what packages my code depends?

 Thanks.
 ___
 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] Re: [Haskell] ANNOUNCE: OpenGLRaw 1.0.0.0

2009-06-11 Thread Krzysztof Skrzętnicki
On Thu, Jun 11, 2009 at 19:37, Felipe Lessafelipe.le...@gmail.com wrote:
 On Thu, Jun 11, 2009 at 06:56:01PM +0200, Sven Panne wrote:
 Version 1.0.0.0 covers the OpenGL 3.1 core, all ARB extensions
 and all EXT extensions.

 What about OpenGL 2.1?  As I understand, Linux won't have OpenGL
 3.0 or 3.1 for at least some months,

 $ glxinfo | grep 'OpenGL version'
 OpenGL version string: 2.1 Mesa 7.5-rc3


On my machine I get:

$ glxinfo | grep -i version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.3
OpenGL version string: 3.0.0 NVIDIA 180.51
OpenGL shading language version string: 1.30 NVIDIA via Cg compiler

So it doesn't appear to be true.

Best regards

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


Re: [Haskell-cafe] Incremental XML parsing with namespaces?

2009-06-09 Thread Krzysztof Skrzętnicki
On Mon, Jun 8, 2009 at 20:39, John Millikinjmilli...@gmail.com wrote:
 I'm trying to convert an XML document, incrementally, into a sequence
 of XML events. A simple example XML document:

 doc xmlns=org:myproject:mainns xmlns:x=org:myproject:otherns
    titleDoc title/title
    x:refabc1234/x:ref
    html xmlns=http://www.w3.org/1999/xhtml;bodyHello world!/body/html
 /doc

 The document can be very large, and arrives in chunks over a socket,
 so I need to be able to feed the text data into a parser and receive
 a list of XML events per chunk. Chunks can be separated in time by
 intervals of several minutes to an hour, so pausing processing for the
 arrival of the entire document is not an option. The type signatures
 would be something like:

 type Namespace = String
 type LocalName = String

 data Attribute = Attribute Namespace LocalName String

 data XMLEvent =
    EventElementBegin Namespace LocalName [Attribute] |
    EventElementEnd Namespace LocalName |
    EventContent String |
   EventError String

 parse :: Parser - String - (Parser, [XMLEvent])

 I've looked at HaXml, HXT, and hexpat, and unless I'm missing
 something, none of them can achieve this:

 + HaXml and hexpat seem to disregard namespaces entirely -- that is,
 the root element is parsed to doc instead of
 (org:myproject:mainns, doc), and the second child is x:ref
 instead of (org:myproject:otherns, ref). Obviously, this makes
 parsing mixed-namespace documents effectively impossible. I found an
 email from 2004[1] that mentions a filter for namespace support in
 HaXml, but no further information and no working code.

I would recommend hexpat to do the job. Contrary to what you are
saying, hexpat does offer namespace handling:
http://hackage.haskell.org/packages/archive/hexpat/0.8/doc/html/Text-XML-Expat-Namespaced.html
Perhaps you need more than that?

Personally I found hexpat to be fast, space efficient and easy to use.

Here is the representation I got for your example. Please note the
namespaces in right places.
*  (toNamespaced ( toQualified t'))
Element {eName = NName {nnNamespace = Just org:myproject:mainns,
nnLocalPart = doc}, eAttrs = [(NName {nnNamespace = Just
http://www.w3.org/2000/xmlns/;, nnLocalPart =
x},org:myproject:otherns),(NName {nnNamespace = Just
org:myproject:mainns, nnLocalPart =
xmlns},org:myproject:mainns)], eChildren = [Text \n,Text 
,Element {eName = NName {nnNamespace = Just org:myproject:mainns,
nnLocalPart = title}, eAttrs = [], eChildren = [Text Doc
title]},Text \n,Text ,Element {eName = NName {nnNamespace =
Just org:myproject:otherns, nnLocalPart = ref}, eAttrs = [],
eChildren = [Text abc1234]},Text \n,Text ,Element {eName =
NName {nnNamespace = Just http://www.w3.org/1999/xhtml;, nnLocalPart
= html}, eAttrs = [(NName {nnNamespace = Just
http://www.w3.org/1999/xhtml;, nnLocalPart =
xmlns},http://www.w3.org/1999/xhtml;)], eChildren = [Element {eName
= NName {nnNamespace = Just http://www.w3.org/1999/xhtml;,
nnLocalPart = body}, eAttrs = [], eChildren = [Text Hello
world!]}]},Text \n]}

Best regards

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


Re: [Haskell-cafe] Incremental XML parsing with namespaces?

2009-06-09 Thread Krzysztof Skrzętnicki
And just to provide an example of working program:

---
module Main where

import Text.XML.Expat.Qualified
import Text.XML.Expat.Namespaced
import Text.XML.Expat.Tree

import qualified Data.ByteString.Lazy as BSL

main = do
f - BSL.readFile doc1.xml
let (tree,error) = parseTree Nothing f
case error of
Nothing - putStrLn Here you are:   (print . toNamespaced .
toQualified $ (tree :: Node String String))
Just err - putStrLn Error!  print err
---


$ ./hexpat-test
Here you are:
Element {eName = NName {nnNamespace = Just org:myproject:mainns,
nnLocalPart = doc}, eAttrs = [(NName {nnNamespace = Just
http://www.w3.org/2000/xmlns/;, nnLocalPart =
x},org:myproject:otherns),(NName {nnNamespace = Just
org:myproject:mainns, nnLocalPart =
xmlns},org:myproject:mainns)], eChildren = [Text \n,Text 
,Element {eName = NName {nnNamespace = Just org:myproject:mainns,
nnLocalPart = title}, eAttrs = [], eChildren = [Text Doc
title]},Text \n,Text ,Element {eName = NName {nnNamespace =
Just org:myproject:otherns, nnLocalPart = ref}, eAttrs = [],
eChildren = [Text abc1234]},Text \n,Text ,Element {eName =
NName {nnNamespace = Just http://www.w3.org/1999/xhtml;, nnLocalPart
= html}, eAttrs = [(NName {nnNamespace = Just
http://www.w3.org/1999/xhtml;, nnLocalPart =
xmlns},http://www.w3.org/1999/xhtml;)], eChildren = [Element {eName
= NName {nnNamespace = Just http://www.w3.org/1999/xhtml;,
nnLocalPart = body}, eAttrs = [], eChildren = [Text Hello
world!]}]},Text \n]}
# we mess with doc1.xml and exchange /doc for /do
$ ./hexpat-test
Error!
XMLParseError mismatched tag (XMLParseLocation {xmlLineNumber = 5,
xmlColumnNumber = 2, xmlByteIndex = 205, xmlByteCount = 0})


Best regards

Krzysztof Skrzętnicki

2009/6/9 Krzysztof Skrzętnicki gte...@gmail.com:
 On Mon, Jun 8, 2009 at 20:39, John Millikinjmilli...@gmail.com wrote:
 I'm trying to convert an XML document, incrementally, into a sequence
 of XML events. A simple example XML document:

 doc xmlns=org:myproject:mainns xmlns:x=org:myproject:otherns
    titleDoc title/title
    x:refabc1234/x:ref
    html xmlns=http://www.w3.org/1999/xhtml;bodyHello 
 world!/body/html
 /doc

 The document can be very large, and arrives in chunks over a socket,
 so I need to be able to feed the text data into a parser and receive
 a list of XML events per chunk. Chunks can be separated in time by
 intervals of several minutes to an hour, so pausing processing for the
 arrival of the entire document is not an option. The type signatures
 would be something like:

 type Namespace = String
 type LocalName = String

 data Attribute = Attribute Namespace LocalName String

 data XMLEvent =
    EventElementBegin Namespace LocalName [Attribute] |
    EventElementEnd Namespace LocalName |
    EventContent String |
   EventError String

 parse :: Parser - String - (Parser, [XMLEvent])

 I've looked at HaXml, HXT, and hexpat, and unless I'm missing
 something, none of them can achieve this:

 + HaXml and hexpat seem to disregard namespaces entirely -- that is,
 the root element is parsed to doc instead of
 (org:myproject:mainns, doc), and the second child is x:ref
 instead of (org:myproject:otherns, ref). Obviously, this makes
 parsing mixed-namespace documents effectively impossible. I found an
 email from 2004[1] that mentions a filter for namespace support in
 HaXml, but no further information and no working code.

 I would recommend hexpat to do the job. Contrary to what you are
 saying, hexpat does offer namespace handling:
 http://hackage.haskell.org/packages/archive/hexpat/0.8/doc/html/Text-XML-Expat-Namespaced.html
 Perhaps you need more than that?

 Personally I found hexpat to be fast, space efficient and easy to use.

 Here is the representation I got for your example. Please note the
 namespaces in right places.
 *  (toNamespaced ( toQualified t'))
 Element {eName = NName {nnNamespace = Just org:myproject:mainns,
 nnLocalPart = doc}, eAttrs = [(NName {nnNamespace = Just
 http://www.w3.org/2000/xmlns/;, nnLocalPart =
 x},org:myproject:otherns),(NName {nnNamespace = Just
 org:myproject:mainns, nnLocalPart =
 xmlns},org:myproject:mainns)], eChildren = [Text \n,Text 
 ,Element {eName = NName {nnNamespace = Just org:myproject:mainns,
 nnLocalPart = title}, eAttrs = [], eChildren = [Text Doc
 title]},Text \n,Text     ,Element {eName = NName {nnNamespace =
 Just org:myproject:otherns, nnLocalPart = ref}, eAttrs = [],
 eChildren = [Text abc1234]},Text \n,Text     ,Element {eName =
 NName {nnNamespace = Just http://www.w3.org/1999/xhtml;, nnLocalPart
 = html}, eAttrs = [(NName {nnNamespace = Just
 http://www.w3.org/1999/xhtml;, nnLocalPart =
 xmlns},http://www.w3.org/1999/xhtml;)], eChildren = [Element {eName
 = NName {nnNamespace = Just http://www.w3.org/1999/xhtml;,
 nnLocalPart = body}, eAttrs = [], eChildren = [Text Hello
 world!]}]},Text \n]}

 Best regards

 Krzysztof Skrzętnicki

___
Haskell-Cafe

Re: [Haskell-cafe] Convert IO Int to Int

2009-06-09 Thread Krzysztof Skrzętnicki
On Tue, Jun 9, 2009 at 16:14, Daniel Fischerdaniel.is.fisc...@web.de wrote:
 Am Dienstag 09 Juni 2009 15:57:24 schrieb Magnus Therning:
 On Tue, Jun 9, 2009 at 2:52 PM, ptrashptr...@web.de wrote:
  Hmm...it am not getting through it. I just want to generate a random
  number and then compare it with other numbers. Something like
 
  r = randomRIO (1, 10)
  if (r  5) then... else ...

 You have to do it inside the IO monad, something like

     myFunc  = do
         r - randomRIO (1, 10
         if r  5
             then ...
             else ...

 /M

 Or make the source of the pseudo-random numbers explicit:

 import System.Random

 function :: (RandomGen g, Random a) = g - other args - result
 function gen whatever
    | r  5     = blah newgen something
    | r  3     = blub newgen somethingElse
    | otherwise = bling
      where
        (r,newgen) = randomR (lo,hi) gen

 and finally, when the programme is run:

 main = do
    args - getArgs
    sg - getStdGen
    foo - thisNThat
    print $ function sg foo

 If you're doing much with random generators, wrap it in a State monad.

To avoid reinventing the wheel one can use excellent package available
on Hackage:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MonadRandom

 The die function simulates the roll of a die, picking a number between 1 and 
 6, inclusive, and returning it in the Rand monad.
 Notice that this code will work with any source of random numbers g.

 die :: (RandomGen g) = Rand g Int
 die = getRandomR (1,6)

 The dice function uses replicate and sequence to simulate the roll of n dice.

 dice :: (RandomGen g) = Int - Rand g [Int]
 dice n = sequence (replicate n die)

 To extract a value from the Rand monad, we can can use evalRandIO.

 main = do
   values - evalRandIO (dice 2)
   putStrLn (show values)

Best regards

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


Re: [Haskell-cafe] Random Number

2009-06-07 Thread Krzysztof Skrzętnicki
On Sun, Jun 7, 2009 at 21:33, ptrashptr...@web.de wrote:

 Hi,

 is the are way (or a build in method) in haskell to get a random number from
 a number bottom to a number top?

 Something like

 let randomNumber = random 1 30

 to get a random number between 1 and 30.

I don't mean to be rude, but did you even tried to read the
documentation? The function you want is here:
http://www.haskell.org/ghc/docs/latest/html/libraries/random/System-Random.html

Before you ask any other questions please read this essay:
http://mattgemmell.com/2008/12/08/what-have-you-tried

Best regards

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


Re: [Haskell-cafe] Stack overflow

2009-05-28 Thread Krzysztof Skrzętnicki
On Thu, May 28, 2009 at 14:41, Bertram Felgenhauer
bertram.felgenha...@googlemail.com wrote:
 Krzysztof Skrzętnicki wrote:
 2009/5/27 Bertram Felgenhauer bertram.felgenha...@googlemail.com:
  I wrote:
  Krzysztof Skrzętnicki wrote:
  The code for modifying the counter:
  (\ msg - atomicModifyIORef ioref (\ cnt - (cntMsg cnt msg,(
 
  atomicModifyIORef does not force the new value of the IORef.
  If the previous contents of the IORef is x, the new contents
  will be a thunk,
 
    (\ cnt - (cntMsg cnt msg,())) x
 
  Sorry, it's slightly worse than that. The contents becomes
 
     sel_0 (\ cnt - (cntMsg cnt msg, ())) x
 
  where sel_0 is basically an RTS internal version of fst.
 
  Instead of reading the new value of the IORef, you could also force the
  old one:
 
     atomicModifyIORef ioref (\ cnt - (cntMsg cnt msg, msg)) = (return $!)
 

 Thanks for the tip, although it seems tricky to get it right. I wonder
 why there is no strict version of atomicModifyIORef?

 Something like this?

 -- | Stricter version of 'atomicModifyIORef', which prevents building
 --   up huge thunks in the 'IORef' due to repeated modification.
 --   Unlike 'atomicModifyIORef', 'atomicModifyIORef'' may block.
 atomicModifyIORef' :: IORef a - (a - (a, b)) - IO b
 atomicModifyIORef' ioref f = do
    res - atomicModifyIORef ioref f
    new - readIORef ioref
    new `seq` return res

 (The step that may block is forcing the new value - if another thread is
 already evaluating part of the thunk, the currently executing thread
 will block, waiting for the other thread to finish.)

 Dually there might be a strict version of IORef datatype.

 One interesting feature of atomicModifyIORef is that its implementation
 is lock-free, and never blocks (which affects exception handling):
 replacing the old value by the new value is done with compare-and-swap
 operation in a tight loop. Each iteration executes very quickly because
 all it does is replace the reference to the old value in the new thunk.

 With a strict IORef, the time window between reading the old value and
 storing the new value would become arbitrarily large, because you'd have
 to force the new value before exchanging it with the old value. So a
 reasonable implementation would have to use locks instead, I think,
 making atomicModifyIORef more expensive, and less useful in contexts
 that block exceptions.

We may as well drop the 'atomic' keyword and provide a warning about
possible blocking of thread. The end user may forkIO the modification
if he wants to.

I modified the code as follows, it works now:
(\ msg - atomicModifyIORef ioref (\ cnt - (cntMsg cnt msg,cnt)) =
(return $!))

Thank you all for your help!

Best regards

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


[Haskell-cafe] Stack overflow

2009-05-27 Thread Krzysztof Skrzętnicki
Hello Cafe

I'm currently writing an app with heavy use of message passing. To see
which messages takes most of the bandwidth I wrote the following code:

--
data Counter = CNT !Int !Int !Int !Int

cntMsg (CNT a b c d) (MoveOther _ _) = (CNT a+1 b c d)
cntMsg (CNT a b c d) (MoveSelf _) = (CNT a b+1 c d)
cntMsg (CNT a b c d) (NilMsg) = (CNT a b c+1 d)
cntMsg (CNT a b c d) (RoundEnd) = (CNT a b c d+1)

emptyCnt = CNT 0 0 0 0
showCnt (CNT a b c d) = printf CNT MoveOther=%d MoveSelf=%d NilMsg=%d
RoundEnd=%d a b c d
--

The code for modifying the counter:
(\ msg - atomicModifyIORef ioref (\ cnt - (cntMsg cnt msg,(

Running it without increased stack blows it. With 200M stack I get
after a second or so:

CNT MoveOther=2125764 MoveSelf=0 NilMsg=0 RoundEnd=2916

The datatype itself is strict. So where is the thunk actually accumulating?

Best regards

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


Re: [Haskell-cafe] Stack overflow

2009-05-27 Thread Krzysztof Skrzętnicki
2009/5/27 Bertram Felgenhauer bertram.felgenha...@googlemail.com:
 I wrote:
 Krzysztof Skrzętnicki wrote:
 The code for modifying the counter:
 (\ msg - atomicModifyIORef ioref (\ cnt - (cntMsg cnt msg,(

 atomicModifyIORef does not force the new value of the IORef.
 If the previous contents of the IORef is x, the new contents
 will be a thunk,

   (\ cnt - (cntMsg cnt msg,())) x

 Sorry, it's slightly worse than that. The contents becomes

    sel_0 (\ cnt - (cntMsg cnt msg, ())) x

 where sel_0 is basically an RTS internal version of fst.

 Instead of reading the new value of the IORef, you could also force the
 old one:

    atomicModifyIORef ioref (\ cnt - (cntMsg cnt msg, msg)) = (return $!)


Thanks for the tip, although it seems tricky to get it right. I wonder
why there is no strict version of atomicModifyIORef?
Dually there might be a strict version of IORef datatype.

Best regards

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


Re: [Haskell-cafe] Example code won't compile

2009-05-15 Thread Krzysztof Skrzętnicki
The one important line is
 import Control.Monad.Error
It adds dependancy on mtl package, which is not used by default
(contrary to 'base' package, which includes Monad, System and IO
modules). With --make GHC adds it automatically. Therefore
$ ghc -package mtl ex14.hs
compiles fine. I'd recommend using --make. In rare occasions when
there is a namespace clash between packages one can simply hide
offending packages or specify preferred ones.

Best regards

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


Re: [Haskell-cafe] Vector-like data structure

2009-05-04 Thread Krzysztof Skrzętnicki
Thank both of you for your responses. Unfortunately I decided to
switch to Python for this project, as I plan to use BerkeleyDB and
Haskell bindings for it are poorly written.

Best regards

Christopher Skrzętnicki

2009/5/3 Don Stewart d...@galois.com:
 gtener:
 Hi

 I'm looking for a data structure with following characteristics:
 1. O(1) lookup
 2. O(1) modification
 3. amortized O(1) append
 4. O(1) size query

 This roughly characterizes C++ vector class. I'm ready to implement
 it myself, but first I would like to ask if anyone knows package with
 similar data structure.
 If there are many, which one would you choose and why?


 A number of the array packages behave like this.  The trie packages are
 O(log(wordsize)), so another option (they tend to have better append
 complexity as well).

 -- Don

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


[Haskell-cafe] Vector-like data structure

2009-05-03 Thread Krzysztof Skrzętnicki
Hi

I'm looking for a data structure with following characteristics:
1. O(1) lookup
2. O(1) modification
3. amortized O(1) append
4. O(1) size query

This roughly characterizes C++ vector class. I'm ready to implement
it myself, but first I would like to ask if anyone knows package with
similar data structure.
If there are many, which one would you choose and why?

Best regards

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


Re: [Haskell-cafe] Array Binary IO molecular simulation

2009-05-02 Thread Krzysztof Skrzętnicki
On Sat, May 2, 2009 at 11:12, Jason Dusek jason.du...@gmail.com wrote:
  I believe Data.Binary includes a header with the data
  it serializes. In consequence, the second and all following
  arrays will be invisible.
[Apologies for Jason for sending this twice to him]

I didn't check the Binary instance for arrays, however I belive it's
not true. Consider Binary instances for tuples:

instance (Binary a, Binary b) = Binary (a,b) where
   put (a,b)   = put a  put b
   get = liftM2 (,) get get

instance (Binary a, Binary b, Binary c) = Binary (a,b,c) where
   put (a,b,c) = put a  put b  put c
   get = liftM3 (,,) get get get

If what you are saying would be true, the tuple instances would be
incorrect for array tuples.

Best regards

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


Re: [Haskell-cafe] Memory usage of cabal install

2009-04-27 Thread Krzysztof Skrzętnicki
Jakiej platformy dokładnie dotyczy Twój problem?
Proponuję upgrade do najnowszej wersji - można ją ściągnąć ze strony GHC.

Pozdrawiam

Krzysztof Skrzętnicki

2009/4/27 Krzysztof Kościuszkiewicz k.kosciuszkiew...@gmail.com:
 Hello Haskell-Café,

 I have a problem with high memory usage of cabal-install.  Whenever I
 try to install or upgrade a package, cabal manages to consume 1,3G of
 memory before I killed it (on a 32-bit machine with 1 GB of memory).

 Increasing verbosity does not help, memory consumption goes up after the
 message Resolving dependencies... shows up.

 I use ghc 6.8.2 and cabal-install version 0.5.1 using version 1.4.0.1 of
 the Cabal library.

 Is there a workaround? I would like to avoid fetching  building packages
 manually.
 --
 Krzysztof Kościuszkiewicz
 Simplicity is the ultimate sophistication -- Leonardo da Vinci
 ___
 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] Binary I/O options

2009-04-24 Thread Krzysztof Skrzętnicki
There is already a network-bytestring package:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-bytestring

Regards

Christopher Skrzętnicki

On Fri, Apr 24, 2009 at 16:20, David Leimbach leim...@gmail.com wrote:

 Sounds like the endorsement I was looking for :-)


 On Fri, Apr 24, 2009 at 7:18 AM, John Van Enk vane...@gmail.com wrote:

 I use Data.Binary to encode/decode all messages/packets in my P2P VPN
 application (http://code.google.com/p/scurry/). It's been quite fast and
 has be suitable for all my needs thus far.

 On Fri, Apr 24, 2009 at 10:15 AM, David Leimbach leim...@gmail.comwrote:

 I see that there are a few approaches to doing Binary I/O with Haskell,
 and the one I'm currently looking at using is Data.Binary from Hackage.  I
 was just wondering what folks were choosing for building networked
 applications and doing Binary I/O.
 The approach I was about to take was to use Data.Binary to create
 ByteString for Network calls with a standard I/O package.  Are there other
 good options?

 Dave

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




 --
 /jve



 ___
 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] Template Haskell + Profiling

2009-04-24 Thread Krzysztof Skrzętnicki
Hi

I'm trying to build some modules that use TH with profiling enabled.

The normal build works:

$ ghc -fforce-recomp --make -cpp -O -DXQUERY2_TEST Main
[1 of 8] Compiling Text.XML.Expat.FormatCustom (
Text/XML/Expat/FormatCustom.hs, Text/XML/Expat/FormatCustom.o )
[2 of 8] Compiling DataStructures   ( DataStructures.hs, DataStructures.o )
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package syb ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package packedstring-0.1.0.1 ... linking ... done.
Loading package containers-0.2.0.1 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package mtl-1.1.0.2 ... linking ... done.
Loading package filepath-1.1.0.2 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.2 ... linking ... done.
Loading package unix-2.3.2.0 ... linking ... done.
Loading package directory-1.0.0.3 ... linking ... done.
Loading package process-1.0.1.1 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package derive-0.1.4 ... linking ... done.
[3 of 8] Compiling Utils( Utils.hs, Utils.o )
[4 of 8] Compiling Semantics.Pure   ( Semantics/Pure.hs, Semantics/Pure.o )
[5 of 8] Compiling Database ( Database.hs, Database.o )
[6 of 8] Compiling XPathDSL ( XPathDSL.hs, XPathDSL.o )
[7 of 8] Compiling QueryParse   ( QueryParse.hs, QueryParse.o )
[8 of 8] Compiling Main ( Main.hs, Main.o )
Linking Main ...

But profiling one fails:

$ ghc -prof -auto -auto-all -fforce-recomp --make -cpp -O -DXQUERY2_TEST
Main
[1 of 8] Compiling Text.XML.Expat.FormatCustom (
Text/XML/Expat/FormatCustom.hs, Text/XML/Expat/FormatCustom.o )
[2 of 8] Compiling DataStructures   ( DataStructures.hs, DataStructures.o )
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
DataStructures.hs:1:0:
Dynamic linking required, but this is a non-standard build (eg. prof).
You need to build the program twice: once the normal way, and then
in the desired way using -osuf to set the object file suffix.

The error message is somewhat cryptic to me. Does anyone know how to perform
profiling build when using TH?

Regards

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


Re: [Haskell-cafe] Haskell Weekly News: Issue 111 - March 28, 2009

2009-03-28 Thread Krzysztof Skrzętnicki
This paper from 1994:
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.36.5611
begins point 1.1 with exactly that sentence. It doesn't seem to be
quoted there, so one can assume this is the original source of that
sentence. I'm not sure dough.

Regards

Christopher Skrzętnicki

2009/3/28 Conal Elliott co...@conal.net:
 conal: Recursion is the goto of functional programming

 BTW, I certainly did not mean to take credit for this wonderful quote.  I
 don't know the origin.  I first heard it from Erik Meijer.

   - Conal


 ___
 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] Telnet handshaking

2009-02-15 Thread Krzysztof Skrzętnicki
On Sun, Feb 15, 2009 at 10:25, Martijn van Steenbergen
mart...@van.steenbergen.nl wrote:
 Are there any Haskell libraries out there that implement telnet? Bare
 sockets are a good approximation, but I'm looking for a library that
 understands the escape sequences specific to telnet.

I think Yogurt
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Yogurt
should implement this. If I'm right then you could simply extract
necessary code.

All best

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


Re: [Haskell-cafe] Re: Overloading functions based on arguments?

2009-02-13 Thread Krzysztof Skrzętnicki
On Fri, Feb 13, 2009 at 22:37, John A. De Goes j...@n-brain.net wrote:
 On Feb 13, 2009, at 2:11 PM, Jonathan Cast wrote:

 The compiler should fail when you tell it two mutually contradictory
 things, and only when you tell it two mutually contradictory things.

 By definition, it's not a contradiction when the symbol is unambiguously
 typeable. Do you think math textbooks are filled with contradictions when
 they give '+' a different meaning for vectors than matrices or real
 numbers???

I can easily imagine a book which uses some operator in ambiguous way
yet relies on readers' intelligence in solving that issue. It is OK to
do that as
long as it is easy. However: it can get arbitrarily worse. I would
consider any book which is hard
to read because of that badly written. Things are quite similar with the code.

 Type is implicitly or explicitly a part of the definition of every function.
 It's not the name that need be unique, but the name over a given domain.
 When two functions have different domains, the same name can be
 unambiguously used to describe both of them.

I think the whole point is not about what is and what isn't possible
to implement.
For example GHC often can do just fine with undecidable instances
despite the problems they may cause.
Programming language should be easy to reason about for both computers
and humans. Compiler should therefore disallow programming style that is
inaccessible for potential readers. Want to overload something? Well,
use typeclasses to
be explicit about it.

All best

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


Re: [Haskell-cafe] Re: [Haskell] Google Summer of Code 2009

2009-02-12 Thread Krzysztof Skrzętnicki
On Thu, Feb 12, 2009 at 11:36, Malcolm Wallace
malcolm.wall...@cs.york.ac.uk wrote:
 Gwern Branwen gwe...@gmail.com wrote:

 * A GUI interface to Darcs
 (http://hackage.haskell.org/trac/summer-of-code/ticket/17);

 I wonder whether darcs ought to apply to be a GSoC mentoring
 organisation in its own right this year?  It would be good to attempt to
 get a couple of dedicated slots for darcs only (in addition to any that
 haskell.org may get).

 * Optimization of containers
 (http://hackage.haskell.org/trac/summer-of-code/ticket/1549). Would
 benefit every Haskell user very quickly.

 This was Jamie Brandon's GSoC project last year, and although that is
 not yet in wide use, I suspect there is very little extra effort needed
 to get it out there into the average Haskell user's hands.

 * XMonad compositing support
 (http://hackage.haskell.org/trac/summer-of-code/ticket/1548).

 Maybe XMonad should also think about whether to apply to GSoC in their
 own right as a mentoring org?  As a project, it seems to have a lot of
 life independent of the Haskell community.


By the way: I think it may be worthwile to contact Google to point out
the recent growth of Haskell community. I don't know on what basis
they assign the slots, but it may be beneficial to do so.

All best

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


Re: [Haskell-cafe] How to deal with utf-8?

2009-02-12 Thread Krzysztof Skrzętnicki
On Fri, Feb 13, 2009 at 08:06, Magicloud magicloud.magiclo...@gmail.com wrote:
 Hi,
   I am using Text.CSV to read and using gtk2hs to display csv files using
 utf-8 encode. Well, it displays broken strings, seems like it cannot deal
 with utf-8.
   What should I do?

You should try using functions from utf8-string package (find it on
Hackage) to read UTF-8 encoded data.
That's about reading data in. I'm not so sure however about the gtk2hs
part. Experts should tell you if it is possible or not. (I think it
is.)

All best

Christopher Skrzętnicki

P.S. I think beginn...@haskell.org is a better place to ask such questions.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Gtk2HS 0.10.0 Released

2009-02-11 Thread Krzysztof Skrzętnicki
2009/2/11 Gwern Branwen gwe...@gmail.com:
 touch tools/c2hs/c2hsLocal.deps;  /home/gwern/bin/bin/ghc -M -dep-makefile
 -optdeptools/c2hs/c2hsLocal.deps -fglasgow-exts -O
  
 -itools/c2hs/base/admin:tools/c2hs/base/errors:tools/c2hs/base/general:tools/c2hs/base/state:tools/c2hs/base/syms:tools/c2hs/base/syntax:tools/c2hs/c:tools/c2hs/chs:tools/c2hs/gen:tools/c2hs/state:tools/c2hs/toplevel
 -package-conf package.conf.inplace -hide-all-packages  -package base-4.0.0.0
 -package haskell98-1.0.1.0 -package pretty-1.0.1.0 -package
 containers-0.2.0.0 -package array-0.2.0.0
  tools/c2hs/base/admin/BaseVersion.hs tools/c2hs/base/admin/Config.hs
 tools/c2hs/base/errors/Errors.hs tools/c2hs/base/general/DLists.hs
 tools/c2hs/base/general/FileOps.hs tools/c2hs/base/general/FNameOps.hs
 tools/c2hs/base/general/Map.hs tools/c2hs/base/general/Position.hs
 tools/c2hs/base/general/Set.hs tools/c2hs/base/general/UNames.hs
 tools/c2hs/base/general/Binary.hs tools/c2hs/base/general/FastMutInt.hs
 tools/c2hs/base/state/CIO.hs tools/c2hs/base/state/StateBase.hs
 tools/c2hs/base/state/State.hs tools/c2hs/base/state/StateTrans.hs
 tools/c2hs/base/syms/Attributes.hs tools/c2hs/base/syms/Idents.hs
 tools/c2hs/base/syms/NameSpaces.hs tools/c2hs/base/syntax/Lexers.hs
 tools/c2hs/c/CAST.hs tools/c2hs/c/CAttrs.hs tools/c2hs/c/CBuiltin.hs
 tools/c2hs/c/C.hs tools/c2hs/c/CLexer.hs tools/c2hs/c/CNames.hs
 tools/c2hs/c/CParser.hs tools/c2hs/c/CParserMonad.hs tools/c2hs/c/CPretty.hs
 tools/c2hs/c/CTokens.hs tools/c2hs/c/CTrav.hs tools/c2hs/chs/CHS.hs
 tools/c2hs/chs/CHSLexer.hs tools/c2hs/gen/CInfo.hs tools/c2hs/gen/GBMonad.hs
 tools/c2hs/gen/GenBind.hs tools/c2hs/gen/GenHeader.hs
 tools/c2hs/state/C2HSState.hs tools/c2hs/state/Switches.hs
 tools/c2hs/toplevel/Main.hs tools/c2hs/toplevel/Version.hs
 tools/c2hs/toplevel/C2HSConfig.hs;
 gcc -E -x c -traditional-cpp -I/usr/include/glib-2.0
 -I/usr/lib/glib-2.0/include -DGTK2HS_HS_PREPROC -include gtk2hs-config.h
 glib/System/Glib/GObject.chs.pp -o glib/System/Glib/GObject.chs
 glib/System/Glib/GObject.chs.pp:38: error: missing expression between '('
 and ')'
 glib/System/Glib/GObject.chs.pp:91: error: missing expression between '('
 and ')'
 make: *** [glib/System/Glib/GObject.chs] Error 1


Ah, It feels familiar. I'm didn't get this error, but I do recall a
recent thread with similar error. However AFAIR that thread was about
building on Windows, not Ubuntu. It turned out that configure script
was somewhat broken and specific symbols needed for CPP where declared
to be empty strings. This might be happening in your case too. I
think.

All best

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


Re: [Haskell-cafe] Re: [Haskell] Google Summer of Code 2009

2009-02-11 Thread Krzysztof Skrzętnicki
On Wed, Feb 11, 2009 at 21:00, Jamie hask...@datakids.org wrote:
 Hi Gwern,

 On Wed, 11 Feb 2009, Gwern Branwen wrote:

 I just checked H.263 and it looks like it does not require patent
 licensing
 at all (it is created by ITU-T Video Coding Experts Group (VCEG)) so one
 can
 write H.263 in Haskell and release freely without patent licensing
 issues.

 So writing H.263 in Haskell could be a good GSoC project.  One mentioned
 that GHC produce slow code, well H.263 could be a good test case to
 improve
 GHC optimization over time.  In The Computer Language Benchmarks Game,
 Haskell has some catching up to do. :)

 It does sound like a reasonably discrete task, and it sounds like you have
 a use for it; but I wonder if it's doable in a single summer?

 I have no idea, I have not dig deeper into H.263 C source code but I guess
 it should be quite trivial as it is a black box with video frame input and
 output with several parameters for encoding and just frame in/out for
 decoding.

I didn't dig into the source code either, but I've just skimmed
through Wikipedia page on that codec:
http://en.wikipedia.org/wiki/H.263
and in seems far from trivial. Anything that has 23 annexes is likely
to be quite complex :-)
Therefore I seriously doubt chances for success of such project. I did
some checks: in libavcodec at least following files consist of
implementation of H.263:

h263.c h263data.h h263dec.c  h263.h
h263_parser.c  h263_parser.h

How many lines are there?

[te...@laptener libavcodec]$ wc h263*
  6295  19280 218932 h263.c
   314   2117  10423 h263data.h
   816   2171  26675 h263dec.c
46217   2032 h263.h
91282   2361 h263_parser.c
29165   1047 h263_parser.h
  7591  24232 261470 razem

In Haskell project one would also need to provide some additional
utility code which is part of libavcodec.
Fast grep shows the tip of an iceberg:

[te...@laptener libavcodec]$ grep include h263* | grep -v 
h263.c:#include dsputil.h
h263.c:#include avcodec.h
h263.c:#include mpegvideo.h
h263.c:#include h263data.h
h263.c:#include mpeg4data.h
h263.c:#include mathops.h
h263data.h:#include mpegvideo.h
h263dec.c:#include avcodec.h
h263dec.c:#include dsputil.h
h263dec.c:#include mpegvideo.h
h263dec.c:#include h263_parser.h
h263dec.c:#include mpeg4video_parser.h
h263dec.c:#include msmpeg4.h
h263.h:#include config.h
h263.h:#include msmpeg4.h
h263_parser.c:#include parser.h
h263_parser.h:#include parser.h



Bottom line: I don't think it is reasonable to assume anyone without
previous knowledge of H.263 is able to fit that project into one
summer. But! It's Haskell community, and people here see the
impossible happen from time to time ;-)

All best

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


Re: [Haskell-cafe] type metaphysics

2009-02-02 Thread Krzysztof Skrzętnicki
Do they? Haskell is a programing language. Therefore legal Haskell types has
to be represented by some string. And there are countably many strings (of
which only a subset is legal type representation, but that's not
important).
All best

Christopher Skrzętnicki

On Mon, Feb 2, 2009 at 17:09, Gregg Reynolds d...@mobileink.com wrote:

 On Mon, Feb 2, 2009 at 10:05 AM, Andrew Butterfield
 andrew.butterfi...@cs.tcd.ie wrote:
  Martijn van Steenbergen wrote:
 
  To my naive mind this sounds
  suspiciously like the set of all sets, so it's too big to be a set.
 
  Here you're probably thinking about the distinction between countable
 and
  uncountable sets. See also:
 
  http://en.wikipedia.org/wiki/Countable_set
 
  No - it's even bigger than those !
 
  He is thinking of proper classes, not sets.
 
  http://en.wikipedia.org/wiki/Class_(set_theory)

 Yes, that's my hypothesis:  type constructors take us outside of set
 theory (ZF set theory, at least).  I just can't prove it.

 Thanks,

 g
 ___
 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] GHC 6.11 missing time package?

2009-02-01 Thread Krzysztof Skrzętnicki
It looks that you need MSYS or Cygwin to complete this build. Here you can
find instructions regarding MSYS (and also GLUT, but you can ignore that
part):
http://www.haskell.org/pipermail/haskell-cafe/2007-September/031535.html

All best

Christopher Skrzętnicki

2009/2/1 Lyle Kopnicky li...@qseep.net

 I tried building it from hackage. I got an error:
 Setup.hs: sh: createProcess: does not exist (No such file or directory)

 ...which is very similar to the error I get if I try to build it using
 6.10:

 Setup.hs: sh: runGenProcess: does not exist (No such file or directory)

 I don't know if there's something wrong with the package, or I don't have
 something set up right to build it on Windows.

 On Sat, Jan 31, 2009 at 10:13 PM, Antoine Latter aslat...@gmail.comwrote:

 2009/1/31 Lyle Kopnicky li...@qseep.net:
  Hi folks,
  I'm getting ready to release a piece of software. Unfortunately due to a
 bug
  in GHC 6.10 on Windows it does not handle Ctrl+C properly. Since the bug
 has
  been fixed (thank you Simon Marlow), I figured I'd download a 6.11 build
 (I
  grabbed the 2009-01-29 version).
  Unfortunately, my project won't build with it because it's missing the
  time-1.1 package. This is sad because I had gone through the trouble to
  rewrite my use of oldtime to use time, thinking it was more
 future-proof. Is
  this an oversight in the nightly build, or is this package going out of
 GHC?
  Thanks,
  Lyle

 Hackage seems to have it:

 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/time

 Does that work?

 -Antoine



 ___
 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] ANN: HDBC v2.0 now available

2009-01-31 Thread Krzysztof Skrzętnicki
On Sat, Jan 31, 2009 at 04:01, John Goerzen jgoer...@complete.org wrote:

 On Sat, Jan 31, 2009 at 01:51:54AM +0100, Krzysztof Skrz??tnicki wrote:
  The following change in .cabal file may solve the problems:---
  flag base4
description: Choose base-4 if possible
default: True
 
  library
if flag(splitBase)
  if flag(base4)
Build-Depends: base=4, old-time, time, bytestring, containers,
  old-locale
  else
Build-Depends: base=3, old-time, time, bytestring, containers,
  old-locale
else
  Build-Depends: base3
Build-Depends: mtl, convertible = 1.0.1, utf8-string
  ---
 
  It works for me and I *think* will also work for other setups, most
 notably
  GHC 6.8.*.

 Not out of the box.  The base4 flag will be on by default for GHC
 6.8.x too, and they'll get the base = 4 dep, which will break.
 They'd have to configure with the option to disable a flag (-f -base4
 if memory serves), which is neither intuitive nor automatic.


No, not really. I downloaded GHC 6.8.3 to test it, and it works:

D:\biblioteki\HDBC-2.0.0cabal install -w c:\ghc\ghc-6.8.3\bin\ghc
Resolving dependencies...
Configuring HDBC-2.0.0.2...
Preprocessing library HDBC-2.0.0.2...
Preprocessing executables for HDBC-2.0.0.2...
Building HDBC-2.0.0.2...
[1 of 7] Compiling Database.HDBC.SqlValue ( Database/HDBC/SqlValue.hs,
dist\build/Database/HDBC/SqlValue.o )
[2 of 7] Compiling Database.HDBC.ColTypes ( Database/HDBC/ColTypes.hs,
dist\build/Database/HDBC/ColTypes.o )
[3 of 7] Compiling Database.HDBC.Statement ( Database/HDBC/Statement.hs,
dist\build/Database/HDBC/Statement.o )

Database/HDBC/Statement.hs:15:0:
Warning: Module `Control.Exception' is imported, but nothing from it is
used,
   except perhaps instances visible in `Control.Exception'
 To suppress this warning, use: import Control.Exception()
[4 of 7] Compiling Database.HDBC.Types ( Database/HDBC/Types.hs,
dist\build/Database/HDBC/Types.o )
[5 of 7] Compiling Database.HDBC.Utils ( Database/HDBC/Utils.hs,
dist\build/Database/HDBC/Utils.o )
[6 of 7] Compiling Database.HDBC.DriverUtils ( Database/HDBC/DriverUtils.hs,
dist\build/Database/HDBC/DriverUtils.o )
[7 of 7] Compiling Database.HDBC( Database/HDBC.hs,
dist\build/Database/HDBC.o )
C:\ghc\ghc-6.10.1\bin\ar.exe: creating dist\build\libHSHDBC-2.0.0.2.a
Installing library in C:\Program Files\Haskell\HDBC-2.0.0.2\ghc-6.8.3
Registering HDBC-2.0.0.2...
Reading package info from dist\\installed-pkg-config ... done.
Saving old package config file... done.
Writing new package config file... done.

Checking:

C:\ghc\ghc-6.8.3\binghc-pkg list HDBC
C:/ghc/ghc-6.8.3\package.conf:
HDBC-2.0.0.2

So both 6.8.3 and 6.10.1 work as expected.

I can't remember the exact page in docs, but as far as i remember if Cabal
fails to satisfy conditions with certain flag on its default settings the
flag is changed and dependency calculation restarts.

All best

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


Re: [Haskell-cafe] can't build testpack

2009-01-31 Thread Krzysztof Skrzętnicki
This error is due to usage of old base package in version 3.In .cabal file
add dependency on base-4, in form base = 4.
All best

Christopher Skrzętnicki

2009/2/1 Ezekiel Smithburg tehgeekmeis...@gmail.com

 this is the error message i get:

 ezekiel-smithburgs-macbook-pro-15% runhaskell Setup.* build
 Preprocessing library testpack-1.0.0...
 Building testpack-1.0.0...
 [1 of 3] Compiling Test.QuickCheck.Instances (
 src/Test/QuickCheck/Instances.hs, dist/build/Test/QuickCheck/Instances.o )
 [2 of 3] Compiling Test.QuickCheck.Tools ( src/Test/QuickCheck/Tools.hs,
 dist/build/Test/QuickCheck/Tools.o )
 [3 of 3] Compiling Test.HUnit.Tools ( src/Test/HUnit/Tools.hs,
 dist/build/Test/HUnit/Tools.o )

 src/Test/HUnit/Tools.hs:28:36:
 Class `Control.Exception.Exception' used as a type
 In the type `Control.Exception.Exception'
 In the type `Control.Exception.Exception - IO a - IO ()'
 In the type `String
  - Control.Exception.Exception - IO a - IO ()'

 what should i do?  need this in order to build hdbc 2.0, which i'm hoping
 solves a problem i was having earlier (memory leak).

 ___
 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] can't build testpack

2009-01-31 Thread Krzysztof Skrzętnicki
2009/2/1 Ezekiel Smithburg tehgeekmeis...@gmail.com

 solution to that problem:

 deleted the lines from If flag(splitBase) on and changed base in
 Build-Depends to base = 4.


Well, this is exactly what I suggested in the first place:

 This error is due to usage of old base package in version 3. In .cabal
file add dependency on base-4, in form base = 4.

Regarding second qustion:

 random 1.0.0.1 is installed, i've verified that.  what does this error
mean?

It means that .cabal file fails to specify dependancy on random package. Add
dependancy on random package next to base=4. This should help.

All best

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


Re: [Haskell-cafe] can't build testpack

2009-01-31 Thread Krzysztof Skrzętnicki
testpack builds fine for me. In the original .cabal file there are following
lines:


 If flag(splitBase)
   Build-Depends: base = 3, containers, random
 Else
   Build-Depends: base  3


Now that I think about it you didn't actually said what is your GHC version.
Knowing that you can replace lines above with one line that matches your
specific configuration.

GHC 6.8.3 :
   Build-Depends: base = 4, containers, random
GHC 6.10.1 :
   Build-Depends: base = 3, containers, random

Please take care to restore and modify the original file.

I think you should read Cabal user guide. This will save your time in the
future:
http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html

I *hope* those changes will fix your installation. I can't really test it,
because testpack build fine with my version of cabal:

C:\Documents and Settings\Methariuscabal install testpack --reinstall
Resolving dependencies...
'testpack-1.0.0' is cached.
Configuring testpack-1.0.0...
Preprocessing library testpack-1.0.0...
Building testpack-1.0.0...
[1 of 3] Compiling Test.QuickCheck.Instances (
src\Test\QuickCheck\Instances.hs, dist\build\Test\QuickCheck\Instances.o )
[2 of 3] Compiling Test.QuickCheck.Tools ( src\Test\QuickCheck\Tools.hs,
dist\build\Test\QuickCheck\Tools.o )
[3 of 3] Compiling Test.HUnit.Tools ( src\Test\HUnit\Tools.hs,
dist\build\Test\HUnit\Tools.o )
C:\ghc\ghc-6.10.1\bin\ar.exe: creating dist\build\libHStestpack-1.0.0.a
Installing library in C:\Program Files\Haskell\testpack-1.0.0\ghc-6.10.1
Registering testpack-1.0.0...
Reading package info from dist\\installed-pkg-config ... done.
Writing new package config file... done.

C:\Documents and Settings\Methariuscabal install -w
c:\ghc\ghc-6.8.3\bin\ghc testpack --reinstall
Resolving dependencies...
'testpack-1.0.0' is cached.
Configuring testpack-1.0.0...
Preprocessing library testpack-1.0.0...
Building testpack-1.0.0...
[1 of 3] Compiling Test.QuickCheck.Instances (
src/Test/QuickCheck/Instances.hs, dist\build/Test/QuickCheck/Instances.o )
[2 of 3] Compiling Test.QuickCheck.Tools ( src/Test/QuickCheck/Tools.hs,
dist\build/Test/QuickCheck/Tools.o )
[3 of 3] Compiling Test.HUnit.Tools ( src/Test/HUnit/Tools.hs,
dist\build/Test/HUnit/Tools.o )
C:\ghc\ghc-6.10.1\bin\ar.exe: creating dist\build\libHStestpack-1.0.0.a
Installing library in C:\Program Files\Haskell\testpack-1.0.0\ghc-6.8.3
Registering testpack-1.0.0...
Reading package info from dist\\installed-pkg-config ... done.
Saving old package config file... done.
Writing new package config file... done.

Perhaps it may also be the difference of installing with cabal install and
runhaskell Setup build.

All best

Christopher Skrzętnicki


2009/2/1 Ezekiel Smithburg tehgeekmeis...@gmail.com

 oddly, when i do that, i'm back to the original error message.  and sorry,
 i didn't understand what you meant, apparently.


 On Sat, Jan 31, 2009 at 7:41 PM, Krzysztof Skrzętnicki 
 gte...@gmail.comwrote:


 2009/2/1 Ezekiel Smithburg tehgeekmeis...@gmail.com

 solution to that problem:

 deleted the lines from If flag(splitBase) on and changed base in
 Build-Depends to base = 4.


 Well, this is exactly what I suggested in the first place:

  This error is due to usage of old base package in version 3. In .cabal
 file add dependency on base-4, in form base = 4.

 Regarding second qustion:

  random 1.0.0.1 is installed, i've verified that.  what does this error
 mean?

 It means that .cabal file fails to specify dependancy on random package.
 Add dependancy on random package next to base=4. This should help.

 All best

 Christopher Skrzętnicki



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


Re: [Haskell-cafe] can't build testpack

2009-01-31 Thread Krzysztof Skrzętnicki
Trying to follow Ezekiel's steps I bumped into this:


D:\biblioteki\testpack-1.0.0cabal configure
Configuring testpack-1.0.0...

D:\biblioteki\testpack-1.0.0cabal build
Preprocessing library testpack-1.0.0...
Building testpack-1.0.0...
[1 of 3] Compiling Test.QuickCheck.Instances (
src\Test\QuickCheck\Instances.hs, dist\build\Test\QuickCheck\Instances.o )
[2 of 3] Compiling Test.QuickCheck.Tools ( src\Test\QuickCheck\Tools.hs,
dist\build\Test\QuickCheck\Tools.o )
[3 of 3] Compiling Test.HUnit.Tools ( src\Test\HUnit\Tools.hs,
dist\build\Test\HUnit\Tools.o )

src\Test\HUnit\Tools.hs:28:36:
Class `Control.Exception.Exception' used as a type
In the type `Control.Exception.Exception'
In the type `Control.Exception.Exception - IO a - IO ()'
In the type `String
 - Control.Exception.Exception - IO a - IO ()'

D:\biblioteki\testpack-1.0.0cabal install
Resolving dependencies...
Configuring testpack-1.0.0...
Preprocessing library testpack-1.0.0...
Building testpack-1.0.0...
[3 of 3] Compiling Test.HUnit.Tools ( src\Test\HUnit\Tools.hs,
dist\build\Test\HUnit\Tools.o )
C:\ghc\ghc-6.10.1\bin\ar.exe: creating dist\build\libHStestpack-1.0.0.a
Installing library in C:\Program Files\Haskell\testpack-1.0.0\ghc-6.10.1
Registering testpack-1.0.0...
Reading package info from dist\\installed-pkg-config ... done.
Writing new package config file... done.


In short: cabal configure  cabal build fails, whereas cabal install
builds fine. Looks like a bug in cabal-install. Am I right?

All best

Christopher Skrzętnicki



On Sun, Feb 1, 2009 at 03:01, Krzysztof Skrzętnicki gte...@gmail.comwrote:

 testpack builds fine for me. In the original .cabal file there are
 following lines:

 
  If flag(splitBase)
Build-Depends: base = 3, containers, random
  Else
Build-Depends: base  3
 

 Now that I think about it you didn't actually said what is your GHC
 version.
 Knowing that you can replace lines above with one line that matches your
 specific configuration.

 GHC 6.8.3 :
Build-Depends: base = 4, containers, random
 GHC 6.10.1 :
Build-Depends: base = 3, containers, random

 Please take care to restore and modify the original file.

 I think you should read Cabal user guide. This will save your time in the
 future:
 http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html

 I *hope* those changes will fix your installation. I can't really test it,
 because testpack build fine with my version of cabal:

 C:\Documents and Settings\Methariuscabal install testpack --reinstall
 Resolving dependencies...
 'testpack-1.0.0' is cached.
 Configuring testpack-1.0.0...
 Preprocessing library testpack-1.0.0...
 Building testpack-1.0.0...
 [1 of 3] Compiling Test.QuickCheck.Instances (
 src\Test\QuickCheck\Instances.hs, dist\build\Test\QuickCheck\Instances.o )
 [2 of 3] Compiling Test.QuickCheck.Tools ( src\Test\QuickCheck\Tools.hs,
 dist\build\Test\QuickCheck\Tools.o )
 [3 of 3] Compiling Test.HUnit.Tools ( src\Test\HUnit\Tools.hs,
 dist\build\Test\HUnit\Tools.o )
 C:\ghc\ghc-6.10.1\bin\ar.exe: creating dist\build\libHStestpack-1.0.0.a
 Installing library in C:\Program Files\Haskell\testpack-1.0.0\ghc-6.10.1
 Registering testpack-1.0.0...
 Reading package info from dist\\installed-pkg-config ... done.
 Writing new package config file... done.

 C:\Documents and Settings\Methariuscabal install -w
 c:\ghc\ghc-6.8.3\bin\ghc testpack --reinstall
 Resolving dependencies...
 'testpack-1.0.0' is cached.
 Configuring testpack-1.0.0...
 Preprocessing library testpack-1.0.0...
 Building testpack-1.0.0...
 [1 of 3] Compiling Test.QuickCheck.Instances (
 src/Test/QuickCheck/Instances.hs, dist\build/Test/QuickCheck/Instances.o )
 [2 of 3] Compiling Test.QuickCheck.Tools ( src/Test/QuickCheck/Tools.hs,
 dist\build/Test/QuickCheck/Tools.o )
 [3 of 3] Compiling Test.HUnit.Tools ( src/Test/HUnit/Tools.hs,
 dist\build/Test/HUnit/Tools.o )
 C:\ghc\ghc-6.10.1\bin\ar.exe: creating dist\build\libHStestpack-1.0.0.a
 Installing library in C:\Program Files\Haskell\testpack-1.0.0\ghc-6.8.3
 Registering testpack-1.0.0...
 Reading package info from dist\\installed-pkg-config ... done.
 Saving old package config file... done.
 Writing new package config file... done.

 Perhaps it may also be the difference of installing with cabal install
 and runhaskell Setup build.

 All best

 Christopher Skrzętnicki


 2009/2/1 Ezekiel Smithburg tehgeekmeis...@gmail.com

 oddly, when i do that, i'm back to the original error message.  and sorry,
 i didn't understand what you meant, apparently.


 On Sat, Jan 31, 2009 at 7:41 PM, Krzysztof Skrzętnicki 
 gte...@gmail.comwrote:


 2009/2/1 Ezekiel Smithburg tehgeekmeis...@gmail.com

 solution to that problem:

 deleted the lines from If flag(splitBase) on and changed base in
 Build-Depends to base = 4.


 Well, this is exactly what I suggested in the first place:

  This error is due to usage of old base package in version 3. In
 .cabal file add dependency on base-4, in form base = 4

Re: [Haskell-cafe] can't build testpack

2009-01-31 Thread Krzysztof Skrzętnicki
You need to reinstall random package with profiling libraries enabled. This
is simple:
 cabal install random --reinstall --enable-library-profiling

I think all libraries that ships with GHC should have profiling libraries
build too, but for some reason it is not so.

All best

Christopher Skrzętnicki

On Sun, Feb 1, 2009 at 03:32, Ezekiel Smithburg tehgeekmeis...@gmail.comwrote:

 tried that version, it gets rid of that error message but now i have this
 one:

 ezekiel-smithburgs-macbook-pro-15% cabal --flag=split-base configure -p
 Configuring testpack-1.0.0...
 ezekiel-smithburgs-macbook-pro-15% cabal build
 Preprocessing library testpack-1.0.0...
 Building testpack-1.0.0...
 [1 of 3] Compiling Test.QuickCheck.Instances (
 src/Test/QuickCheck/Instances.hs, dist/build/Test/QuickCheck/Instances.o )
 [2 of 3] Compiling Test.QuickCheck.Tools ( src/Test/QuickCheck/Tools.hs,
 dist/build/Test/QuickCheck/Tools.o )
 [3 of 3] Compiling Test.HUnit.Tools ( src/Test/HUnit/Tools.hs,
 dist/build/Test/HUnit/Tools.o )

 src/Test/HUnit/Tools.hs:23:7:
 Could not find module `System.Random':
   Perhaps you haven't installed the profiling libraries for package
 random-1.0.0.1?
   Use -v to see a list of the files searched for.

 i'll start reading the cabal user guide and see if i can figure it out on
 my own, but i figure progress on this should be up on the list so if someone
 else has this problem, they can find this and solve it on their own.  also,
 if someone else can figure it out before i do, that's cool too.

 thanks for your help so far!


 On Sat, Jan 31, 2009 at 8:14 PM, Krzysztof Skrzętnicki 
 gte...@gmail.comwrote:

 Ok, sorry for the confusion, I should have checked it before: testpack
 doesn't really need base-4, it needs base-3.The right dependency line is
 (for both 6.10.1 and 6.8.3):

  Build-Depends: base = 3   4 , containers, random

 I really need to get some sleep...

 All best

 Christopher Skrzętnicki


 On Sun, Feb 1, 2009 at 03:07, Krzysztof Skrzętnicki gte...@gmail.comwrote:

 Trying to follow Ezekiel's steps I bumped into this:

 
 D:\biblioteki\testpack-1.0.0cabal configure
 Configuring testpack-1.0.0...

 D:\biblioteki\testpack-1.0.0cabal build
 Preprocessing library testpack-1.0.0...
 Building testpack-1.0.0...
 [1 of 3] Compiling Test.QuickCheck.Instances (
 src\Test\QuickCheck\Instances.hs, dist\build\Test\QuickCheck\Instances.o )
 [2 of 3] Compiling Test.QuickCheck.Tools ( src\Test\QuickCheck\Tools.hs,
 dist\build\Test\QuickCheck\Tools.o )
 [3 of 3] Compiling Test.HUnit.Tools ( src\Test\HUnit\Tools.hs,
 dist\build\Test\HUnit\Tools.o )

 src\Test\HUnit\Tools.hs:28:36:
 Class `Control.Exception.Exception' used as a type
 In the type `Control.Exception.Exception'
 In the type `Control.Exception.Exception - IO a - IO ()'
 In the type `String
  - Control.Exception.Exception - IO a - IO ()'

 D:\biblioteki\testpack-1.0.0cabal install
 Resolving dependencies...
  Configuring testpack-1.0.0...
 Preprocessing library testpack-1.0.0...
 Building testpack-1.0.0...
 [3 of 3] Compiling Test.HUnit.Tools ( src\Test\HUnit\Tools.hs,
 dist\build\Test\HUnit\Tools.o )
 C:\ghc\ghc-6.10.1\bin\ar.exe: creating dist\build\libHStestpack-1.0.0.a
 Installing library in C:\Program Files\Haskell\testpack-1.0.0\ghc-6.10.1
 Registering testpack-1.0.0...
 Reading package info from dist\\installed-pkg-config ... done.
 Writing new package config file... done.
 

 In short: cabal configure  cabal build fails, whereas cabal install
 builds fine. Looks like a bug in cabal-install. Am I right?

 All best

 Christopher Skrzętnicki



 On Sun, Feb 1, 2009 at 03:01, Krzysztof Skrzętnicki gte...@gmail.comwrote:

 testpack builds fine for me. In the original .cabal file there are
 following lines:

 
  If flag(splitBase)
Build-Depends: base = 3, containers, random
  Else
Build-Depends: base  3
 

 Now that I think about it you didn't actually said what is your GHC
 version.
 Knowing that you can replace lines above with one line that matches your
 specific configuration.

 GHC 6.8.3 :
Build-Depends: base = 4, containers, random
 GHC 6.10.1 :
Build-Depends: base = 3, containers, random

 Please take care to restore and modify the original file.

 I think you should read Cabal user guide. This will save your time in
 the future:
 http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html

 I *hope* those changes will fix your installation. I can't really test
 it, because testpack build fine with my version of cabal:

 C:\Documents and Settings\Methariuscabal install testpack --reinstall
 Resolving dependencies...
 'testpack-1.0.0' is cached.
 Configuring testpack-1.0.0...
 Preprocessing library testpack-1.0.0...
 Building testpack-1.0.0...
 [1 of 3] Compiling Test.QuickCheck.Instances (
 src\Test\QuickCheck\Instances.hs, dist\build\Test\QuickCheck\Instances.o )
 [2 of 3] Compiling Test.QuickCheck.Tools ( src\Test\QuickCheck\Tools.hs,
 dist\build\Test\QuickCheck\Tools.o

Re: [Haskell-cafe] ANN: HDBC v2.0 now available

2009-01-30 Thread Krzysztof Skrzętnicki
On Sat, Jan 31, 2009 at 00:07, Valentyn Kamyshenko kam...@kamysh.orgwrote:

 Hello John,

 I'm trying to install the new version of HDBC on my Mac (ghc version is
 6.10.1), and get the following error:

 # cabal upgrade --global
 Resolving dependencies...
 'HDBC-2.0.0' is cached.
 Configuring HDBC-2.0.0...
 Preprocessing library HDBC-2.0.0...
 Preprocessing executables for HDBC-2.0.0...
 Building HDBC-2.0.0...
 [1 of 7] Compiling Database.HDBC.SqlValue ( Database/HDBC/SqlValue.hs,
 dist/build/Database/HDBC/SqlValue.o )
 [2 of 7] Compiling Database.HDBC.ColTypes ( Database/HDBC/ColTypes.hs,
 dist/build/Database/HDBC/ColTypes.o )
 [3 of 7] Compiling Database.HDBC.Statement ( Database/HDBC/Statement.hs,
 dist/build/Database/HDBC/Statement.o )

 Database/HDBC/Statement.hs:113:9:
Type constructor `Exception' used as a class
In the instance declaration for `Exception SqlError'
 cabal: Error: some packages failed to install:
 HDBC-2.0.0 failed during the building phase. The exception was:
 exit: ExitFailure 1


I got the same error: Windows XP, GHC 6.10.1.
For some reason imported Control.Exception module appears to be 6.8.*
version.

All best

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


Re: [Haskell-cafe] ANN: HDBC v2.0 now available

2009-01-30 Thread Krzysztof Skrzętnicki
On Sat, Jan 31, 2009 at 00:45, Krzysztof Skrzętnicki gte...@gmail.comwrote:

 On Sat, Jan 31, 2009 at 00:07, Valentyn Kamyshenko kam...@kamysh.orgwrote:

 Hello John,

 I'm trying to install the new version of HDBC on my Mac (ghc version is
 6.10.1), and get the following error:

 # cabal upgrade --global
 Resolving dependencies...
 'HDBC-2.0.0' is cached.
 Configuring HDBC-2.0.0...
 Preprocessing library HDBC-2.0.0...
 Preprocessing executables for HDBC-2.0.0...
 Building HDBC-2.0.0...
 [1 of 7] Compiling Database.HDBC.SqlValue ( Database/HDBC/SqlValue.hs,
 dist/build/Database/HDBC/SqlValue.o )
 [2 of 7] Compiling Database.HDBC.ColTypes ( Database/HDBC/ColTypes.hs,
 dist/build/Database/HDBC/ColTypes.o )
 [3 of 7] Compiling Database.HDBC.Statement ( Database/HDBC/Statement.hs,
 dist/build/Database/HDBC/Statement.o )

 Database/HDBC/Statement.hs:113:9:
Type constructor `Exception' used as a class
In the instance declaration for `Exception SqlError'
 cabal: Error: some packages failed to install:
 HDBC-2.0.0 failed during the building phase. The exception was:
 exit: ExitFailure 1


 I got the same error: Windows XP, GHC 6.10.1.
 For some reason imported Control.Exception module appears to be 6.8.*
 version.


I found a (temporary) fix: change dependancy in .cabal file to state base
= 4. Otherwise cabal-install selects base-3 which is the cause of the
problems.

All best

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


Re: [Haskell-cafe] ANN: HDBC v2.0 now available

2009-01-30 Thread Krzysztof Skrzętnicki
The following change in .cabal file may solve the problems:---
flag base4
  description: Choose base-4 if possible
  default: True

library
  if flag(splitBase)
if flag(base4)
  Build-Depends: base=4, old-time, time, bytestring, containers,
old-locale
else
  Build-Depends: base=3, old-time, time, bytestring, containers,
old-locale
  else
Build-Depends: base3
  Build-Depends: mtl, convertible = 1.0.1, utf8-string
---

It works for me and I *think* will also work for other setups, most notably
GHC 6.8.*.

All best

Christopher Skrzętnicki

On Sat, Jan 31, 2009 at 01:31, John Goerzen jgoer...@complete.org wrote:

 On Sat, Jan 31, 2009 at 12:52:02AM +0100, Krzysztof Skrz??tnicki wrote:
   I got the same error: Windows XP, GHC 6.10.1.
   For some reason imported Control.Exception module appears to be 6.8.*
   version.
  
 
  I found a (temporary) fix: change dependancy in .cabal file to state
 base
  = 4. Otherwise cabal-install selects base-3 which is the cause of the
  problems.

 Thanks for the hint for folks.

 Why would cabal-install select a different base than running Setup
 manually?

 I can't hard-code base = 4 into .cabal because that would break for
 GHC 6.8 users.  I have CPP code that selects what to compile based on
 GHC version.

 -- John

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


Re: [Haskell-cafe] how to implement daemon start and stop directives?

2009-01-25 Thread Krzysztof Skrzętnicki
When you succeed please write about it - I'd love to read about it!I was
interested in writing a deamon in the past but didn't have time for it and a
nice tutorial would probably help a lot.

All best

Christopher Skrzętnicki

On Sun, Jan 25, 2009 at 02:57, Belka lambda-be...@yandex.ru wrote:


 If you want a normal daemon, you want to look at System.Posix.Process
 to create a proper daemon (forkProcess, createSession; don't forget to
 close stdOutput (and, errr, Haskell library types:  stdin and stderr
 are where?  not System.Posix.IO with stdOutput) and reopen them on /
 dev/null, at least if they're ttys as determined by
 System.Posix.Terminal.queryTerminal).  You also want to write out a
 pidfile (/var/run/programname.pid) for use by startproc / killproc,
 and you want to install a handler for sigTERM
 (System.Posix.Signals.installHandler) which sets the exit flag (TVar,
 MVar, IORef, Chan, take your pick).  Ideally you also catch sigHUP and
 reload your state.

 Thanks for the guide, Brandon !!

 By the way, I found a piece of code with function (daemonize :: IO () - IO
 ()) (http://sneakymustard.com/2008/12/11/haskell-daemons), which is close
 to
 the subject.

 I guess now I'm ready to implement my own daemon!
 Thanks for your help, everyboby!! =)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Employment

2009-01-23 Thread Krzysztof Skrzętnicki
There are quite a few people with working Haskell knowledge in Wroclaw. I'm
sure many of my colleagues (from University of Wroclaw:
http://www.ii.uni.wroc.pl/ http://www.ii.uni.wroc.pl/cms/)
know Haskell and I think would enjoy working with it.

All best

Christopher Skrzętnicki

On Fri, Jan 23, 2009 at 23:31, Bartosz Wójcik bar...@sudety.it wrote:

 On Monday 19 January 2009 23:26:09 Sittampalam, Ganesh wrote:
  We (Credit Suisse) have Haskell developers in both London and NY,
  although the page only listed NY (I've now corrected it).

 If CS had Haskell positions in Wroclaw, Poland I'd apply for it!
 Best,
 Bartek


 ___
 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] Re: Does readFile /proc/mounts hang for you?

2009-01-21 Thread Krzysztof Skrzętnicki
Same for me:
Linux tenserwer 2.6.28-ARCH #1 SMP PREEMPT Tue Jan 6 10:26:22 UTC 2009
i686 AMD Athlon(tm) 64 Processor 3000+ AuthenticAMD GNU/Linux
The Glorious Glasgow Haskell Compilation System, version 6.10.1

All best

Christopher Skrzętnicki

On Wed, Jan 21, 2009 at 23:27, Ertugrul Soeylemez e...@ertes.de wrote:
 David Fox dds...@gmail.com wrote:

 I posted a bug about this
 (http://hackage.haskell.org/trac/ghc/ticket/2971) but its so odd I had
 to ask here.  Using ghc 6.10.1, both readFile /proc/mounts and
 Data.ByteString.Lazy.Char8.readFile /proc/mounts hang on an amd64
 machine running Linux.  Also, Data.ByteString.readFile /proc/mounts
 returns the empty string.  Is this behavior present for others?  On
 i386?

 I can confirm this on Athlon64 X2 with GHC 6.10.1 running Linux 2.6.25.
 Same behavior here.


 Greets,
 Ertugrul.


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


 ___
 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] real haskell difficulties (at least for me)

2009-01-13 Thread Krzysztof Skrzętnicki
My experience from using GHC under Windows XP is very similar. Many
packages (especially those involving bindings to C packages) are at
least painful to build.
Regarding encoding package: it compiles fine for me:

C:\Documents and Settings\Methariuscabal install encoding
Resolving dependencies...
Downloading encoding-0.4.1...
Configuring encoding-0.4.1...
Preprocessing library encoding-0.4.1...
Building encoding-0.4.1...
[ 1 of 37] Compiling Data.Encoding.Helper.Template (
Data\Encoding\Helper\Template.hs,
dist\build\Data\Encoding\Helper\Template.o )
[ 2 of 37] Compiling Data.Encoding.GB18030Data (
Data\Encoding\GB18030Data.hs, dist\build\Data\Encoding\GB18030Data.o )
[ 3 of 37] Compiling Data.Encoding.Base ( Data\Encoding\Base.hs,
dist\build\Data\Encoding\Base.o )
[ 4 of 37] Compiling Data.Encoding.GB18030 ( Data\Encoding\GB18030.hs,
dist\build\Data\Encoding\GB18030.o )
[ 5 of 37] Compiling Data.Encoding.KOI8U ( Data\Encoding\KOI8U.hs,
dist\build\Data\Encoding\KOI8U.o )
[ 6 of 37] Compiling Data.Encoding.KOI8R ( Data\Encoding\KOI8R.hs,
dist\build\Data\Encoding\KOI8R.o )
[ 7 of 37] Compiling Data.Encoding.CP1258 ( Data\Encoding\CP1258.hs,
dist\build\Data\Encoding\CP1258.o )
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package syb ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package containers-0.2.0.0 ... linking ... done.
Loading package packedstring-0.1.0.1 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package bytestring-0.9.1.4 ... linking ... done.
Loading package regex-base-0.72.0.2 ... linking ... done.
Loading package regex-posix-0.72.0.3 ... linking ... done.
Loading package regex-compat-0.71.0.1 ... linking ... done.
Loading package base-3.0.3.0 ... linking ... done.
[ 8 of 37] Compiling Data.Encoding.CP1257 ( Data\Encoding\CP1257.hs,
dist\build\Data\Encoding\CP1257.o )
[ 9 of 37] Compiling Data.Encoding.CP1256 ( Data\Encoding\CP1256.hs,
dist\build\Data\Encoding\CP1256.o )
[10 of 37] Compiling Data.Encoding.CP1255 ( Data\Encoding\CP1255.hs,
dist\build\Data\Encoding\CP1255.o )
[11 of 37] Compiling Data.Encoding.CP1254 ( Data\Encoding\CP1254.hs,
dist\build\Data\Encoding\CP1254.o )
[12 of 37] Compiling Data.Encoding.CP1253 ( Data\Encoding\CP1253.hs,
dist\build\Data\Encoding\CP1253.o )
[13 of 37] Compiling Data.Encoding.CP1252 ( Data\Encoding\CP1252.hs,
dist\build\Data\Encoding\CP1252.o )
[14 of 37] Compiling Data.Encoding.CP1251 ( Data\Encoding\CP1251.hs,
dist\build\Data\Encoding\CP1251.o )
[15 of 37] Compiling Data.Encoding.CP1250 ( Data\Encoding\CP1250.hs,
dist\build\Data\Encoding\CP1250.o )
[16 of 37] Compiling Data.Encoding.BootString (
Data\Encoding\BootString.hs, dist\build\Data\Encoding\BootString.o )
[17 of 37] Compiling Data.Encoding.ISO885916 (
Data\Encoding\ISO885916.hs, dist\build\Data\Encoding\ISO885916.o )
[18 of 37] Compiling Data.Encoding.ISO885915 (
Data\Encoding\ISO885915.hs, dist\build\Data\Encoding\ISO885915.o )
[19 of 37] Compiling Data.Encoding.ISO885914 (
Data\Encoding\ISO885914.hs, dist\build\Data\Encoding\ISO885914.o )
[20 of 37] Compiling Data.Encoding.ISO885913 (
Data\Encoding\ISO885913.hs, dist\build\Data\Encoding\ISO885913.o )
[21 of 37] Compiling Data.Encoding.ISO885911 (
Data\Encoding\ISO885911.hs, dist\build\Data\Encoding\ISO885911.o )
[22 of 37] Compiling Data.Encoding.ISO885910 (
Data\Encoding\ISO885910.hs, dist\build\Data\Encoding\ISO885910.o )
[23 of 37] Compiling Data.Encoding.ISO88599 (
Data\Encoding\ISO88599.hs, dist\build\Data\Encoding\ISO88599.o )
[24 of 37] Compiling Data.Encoding.ISO88598 (
Data\Encoding\ISO88598.hs, dist\build\Data\Encoding\ISO88598.o )
[25 of 37] Compiling Data.Encoding.ISO88597 (
Data\Encoding\ISO88597.hs, dist\build\Data\Encoding\ISO88597.o )
[26 of 37] Compiling Data.Encoding.ISO88596 (
Data\Encoding\ISO88596.hs, dist\build\Data\Encoding\ISO88596.o )
[27 of 37] Compiling Data.Encoding.ISO88595 (
Data\Encoding\ISO88595.hs, dist\build\Data\Encoding\ISO88595.o )
[28 of 37] Compiling Data.Encoding.ISO88594 (
Data\Encoding\ISO88594.hs, dist\build\Data\Encoding\ISO88594.o )
[29 of 37] Compiling Data.Encoding.ISO88593 (
Data\Encoding\ISO88593.hs, dist\build\Data\Encoding\ISO88593.o )
[30 of 37] Compiling Data.Encoding.ISO88592 (
Data\Encoding\ISO88592.hs, dist\build\Data\Encoding\ISO88592.o )
[31 of 37] Compiling Data.Encoding.ISO88591 (
Data\Encoding\ISO88591.hs, dist\build\Data\Encoding\ISO88591.o )
[32 of 37] Compiling Data.Encoding.UTF32 ( Data\Encoding\UTF32.hs,
dist\build\Data\Encoding\UTF32.o )
[33 of 37] Compiling Data.Encoding.UTF16 ( Data\Encoding\UTF16.hs,
dist\build\Data\Encoding\UTF16.o )
[34 of 37] Compiling Data.Encoding.UTF8 ( Data\Encoding\UTF8.hs,
dist\build\Data\Encoding\UTF8.o )
[35 of 37] Compiling Data.Encoding.ASCII ( Data\Encoding\ASCII.hs,
dist\build\Data\Encoding\ASCII.o )
[36 of 37] Compiling 

Re: [Haskell-cafe] Data.List.sort, not so good?

2008-12-29 Thread Krzysztof Skrzętnicki
I think you are repeating my steps :-) On sorted data (like [1..n])
quicksort is O(n^2).

Please read this thread:
http://www.nabble.com/(flawed-)-benchmark-:-sort-td15817832.html

All best

Christopher Skrzętnicki


2008/12/29 Adrian Neumann aneum...@inf.fu-berlin.de:
 Ah that's interesting. Now my Mergesort is exactly as fast as List.sort. I
 thought GHC was smart enough to do that kind of inter-module optimisation.

 Still, Quicksort is twice as fast, so at least one argument for a
 Data.List.Sort package on hackage remains.


 Am 29.12.2008 um 16:43 schrieb Bayley, Alistair:

 From: haskell-cafe-boun...@haskell.org
 [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Adrian Neumann

 I don't consider myself to be a very advanced Haskell
 programmer, but
 I could come up with a Mergesort that beats List.sort, time- and
 spacewise.

 http://hpaste.org/13403

 On my machine List.sort takes ~10 sec, mergeSort 7, qs 4 (compiled
 with -O2). List.sort eats too much ram to sort 20.000.000 ints, my
 algorithms don't.
 QuickCheck says my implementations are correct.


 Your single module might be benefiting from optimisation; specifically,
 specialisation to Ints, which would allow the dictionary lookup to be
 removed. Can you get the same performance if you move your mergeSort 
 qs functions into a separate module, and only export mergeSort  qs?

 Alistair
 *
 Confidentiality Note: The information contained in this message,
 and any attachments, may contain confidential and/or privileged
 material. It is intended solely for the person(s) or entity to
 which it is addressed. Any review, retransmission, dissemination,
 or taking of any action in reliance upon this information by
 persons or entities other than the intended recipient(s) is
 prohibited. If you received this in error, please contact the
 sender and delete the material from any computer.
 *



 ___
 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] implementing python-style dictionary in Haskell

2008-11-18 Thread Krzysztof Skrzętnicki
2008/11/18 kenny lu [EMAIL PROTECTED]:
 Dear all,

 I am trying to implement the python-style dictionary in Haskell.

 Python dictionary is a data structure that maps one key to one value.
 For instance, a python dictionary
 d = {'a':1, 'b':2 }
 maps key 'a' to 1, 'b' to 2.
 Python dictionary allows for update. e.g. the statement
 d['a'] = 3
 changes the value pointed by 'a' from 1 to 3.

 Internally, python dictionary is implemented using hash table.

 My first attempt is to use Data.HashTable. However it was immediately
 abandoned, as I realize the memory usage is unreasonably huge.

 ...

 I tested all three implementations by building a dictionary of size 100.
 The result shows that the Map and the Trie approaches handle collision well,
 but
 the IntMap approach does not.


 Here is a comparison of memory usage

 Map : 345 MB
 IntMap : 146 MB
 Trie : 282 MB
 Python : 94 MB

 Here is a comparison of execution time (on an intel dual core 2.0G)

 Map: 26 sec
 IntMap: 9 sec
 Trie: 12 sec
 Python: 2.24 sec


 The above number shows that my implementations of python style dictionary
 are space/time in-efficient as compared to python.

 Can some one point out what's wrong with my implementations?


First of all, you use Strings. That's a very bad thing when you care
about memory restrictions. Fire up ghci type something like this:
 let aas = replicate (1024*1024*10) 'a'
 -- 22 Mb memory usage
 length aas
 10485760
 -- 270 Mb memory usage
10 Mb string caused as much as 250 Mb increase in ghci's memory consumption.

My guess? Use hashtables with ByteStrings.
I rewrote part of your code. Results are quite promising.

Haskell:
121 Mb total memory in use

 INIT  time0.02s  (  0.00s elapsed)
 MUT   time0.84s  (  1.00s elapsed)
 GCtime1.97s  (  2.02s elapsed)
 EXIT  time0.00s  (  0.00s elapsed)
 Total time2.83s  (  3.02s elapsed)

 %GC time  69.6%  (66.8% elapsed)
Python:
$ time python dict.py
256

real0m2.278s
user0m2.233s
sys 0m0.078s

memory: 101 Mb (as reported by Windows' Task Manager).

The code:

--- cut ---

import qualified Data.ByteString.Lazy.Char8 as BS
import Data.Int
import Data.Bits

(...)

parse_a_line_BS :: BS.ByteString - (BS.ByteString,Int)
parse_a_line_BS line = case BS.words line of
  [key,val] - (key,(read . BS.unpack) val)
  _ - error  parse error.  


main :: IO ()
main = do
  dict - HT.new (==) hashByteString
  indata - (map parse_a_line_BS `fmap` BS.lines `fmap` BS.readFile in.txt)
  mapM_ (\ (k,v) - HT.insert dict k v) indata
  HT.lookup dict (BS.pack key256) = \v - case v of
Just vv - putStrLn (show vv)
Nothing - putStrLn
(Not found)

-- derived from Data.HashTable.hashString
hashByteString :: BS.ByteString - Int32
hashByteString = BS.foldl' f golden
   where f m c = fromIntegral (ord c) * magic + hashInt32 m
 magic = 0xdeadbeef

hashInt32 :: Int32 - Int32
hashInt32 x = mulHi x golden + x

mulHi :: Int32 - Int32 - Int32
mulHi a b = fromIntegral (r `shiftR` 32)
   where r :: Int64
 r = fromIntegral a * fromIntegral b

golden :: Int32
golden = 1013904242 -- = round ((sqrt 5 - 1) * 2^32) :: Int32

--- cut ---

I had to rewrite hashString to work for ByteStrings - basically it's
just using different foldl'.

All best

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


Re: [Haskell-cafe] catting to cat gets stuck at 135K

2008-11-10 Thread Krzysztof Skrzętnicki

 Yep, that's your problem.  forkIO the hPut.


I can see the that thing biting a lot of people. Maybe there should be
a warning in docs that this particular combination:

   feed input
   read output
   waitForProcess

is just likely to produce deadlocks?

All best

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


Re: [Haskell-cafe] Password hashing

2008-10-28 Thread Krzysztof Skrzętnicki
On Tue, Oct 28, 2008 at 16:42, Bit Connor [EMAIL PROTECTED] wrote:
 Hello,

 What library can be used to securely hash passwords? From what I
 understand, the bcrypt algorithm is what the experts recommend. It
 is described in the paper:

 http://www.openbsd.org/papers/bcrypt-paper.ps

 I couldn't find a haskell library for this.

 There is a BSD licensed C implementation that looks very simple here:

 http://www.mindrot.org/projects/py-bcrypt/

 A translation to haskell should be straight forward.
 Alternatively, a haskell bcrypt library could directly use this
 implementation and provide a very light FFI wrapper.

 Any thoughts?

Direct Haskell implementation has significant advantage of being more
portable: from my experience building C libraries on Windows is much
more complicated and quite often fails in default setting [1]. Fixing
it may require some non-trivial (and time consuming) hacking. On the
other hand reusing existing implementation is likely to be faster from
developers view: just write a bunch of FFI imports and you are done.
It may also benefit from C's high speed.

All best

Christopher Skrzętnicki

[1] All regex-*, OpenGL and bunch of others
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Glob 0.1, globbing library

2008-10-18 Thread Krzysztof Skrzętnicki
On Fri, Oct 17, 2008 at 22:02, Matti Niemenmaa
[EMAIL PROTECTED] wrote:
 Greetings to all,

 I hereby announce the release of Glob 0.1, a small library for glob-matching
 purposes based on a subset of zsh's syntax.

 Web page at: http://iki.fi/matti.niemenmaa/glob/index.html
 Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Glob

 Simple example: match (compile foo*baz) foobarbaz == True.

 It can also group the contents of a directory given a list of patterns to 
 match:
 globDir [compile foo*baz] a directory containing foobarbaz and joe gives
 ([dir/foobarbaz],[dir/joe]).

 Comments, complaints, feature requests, bug reports are all welcome. It should
 work on both GHC 6.8 and 6.10, but I've only tested the latter.


Hello

I tried out your package, but it doesn't seem to work correctly on
Windows. I checked the code and it has directory separator hard coded,
which seem to be the source of problems. Please see:

http://www.haskell.org/ghc/docs/latest/html/libraries/filepath/System-FilePath-Posix.html#v%3ApathSeparators

All best

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


Re: [Haskell-cafe] ANNOUNCE: Glob 0.1, globbing library

2008-10-18 Thread Krzysztof Skrzętnicki
On Sat, Oct 18, 2008 at 19:28, Matti Niemenmaa
[EMAIL PROTECTED] wrote:
 Gah, I fail at posting to mailing lists. For posterity, the message I sent to
 Krzysztof:

 Krzysztof Skrzętnicki wrote:
 On Fri, Oct 17, 2008 at 22:02, Matti Niemenmaa [EMAIL PROTECTED]
 wrote:
 Web page at: http://iki.fi/matti.niemenmaa/glob/index.html Hackage:
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Glob

 I tried out your package, but it doesn't seem to work correctly on Windows. I
 checked the code and it has directory separator hard coded, which seem to be
 the source of problems.

 Interesting, given that I've only tested it on Windows. ;-) Can you give an
 example which doesn't work?


Ouch... I feel like I deserve an entry on http://failblog.org/
Somehow I assumed that globDir has type
[Pattern] - FilePath - IO [FilePath]
where in reality it has type
[Pattern] - FilePath - IO ([[FilePath]], [FilePath])

When I saw lots of files that didn't match my query I thought there is a bug...
I'll certainly doublecheck any bug reports before submitting.
Sorry for the noise.

All best

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


Re: [Haskell-cafe] I'll do USB in Haskell - tips?

2008-10-06 Thread Krzysztof Skrzętnicki
On Tue, Oct 7, 2008 at 01:55, Mauricio [EMAIL PROTECTED] wrote:
 Hi,

 I'll need to use a lot of USB at work and, after
 looking around, it seems there's no general USB
 code done. 'libusb' and 'openusb' do not seem
 ready enough so that wrapping them would be easier
 than writing from scratch. (If you think I am
 wrong until here and have time to write me your
 opinion, I'll value it a lot.)

Have a look at libusb version 1.0 API. It looks pretty promising:

http://libusb.wiki.sourceforge.net/Libusb1.0

All best

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


Re: [Haskell-cafe] cabal upgrade

2008-10-01 Thread Krzysztof Skrzętnicki
On Thu, Oct 2, 2008 at 00:00, Svein Ove Aas [EMAIL PROTECTED] wrote:
 That aside, why not start downloading in the background, while it's
 doing whatever you started cabal for? Assuming the network is working,
 you should have an updated package list by the time it's done;
 granted, it won't be used for *that* invocation, but next time you
 invoke cabal it will. If the download fails, just ignore it.

Personally I don't like the idea: If we know that there is newer
package list, why not use it? It feels somewhat unintuitive to me.

All best

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


Re: [Haskell-cafe] not able to compile Happy GLR examples

2008-09-29 Thread Krzysztof Skrzętnicki
 with Happy, version 1.16. I'm using ghc version 6.6.1. I've looked at the

Just looking at the GHC version number: perhaps update to 6.8.3 would help?

Best regards

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


Re: [Haskell-cafe] Where is OpenGL loadMatrix ?

2008-09-25 Thread Krzysztof Skrzętnicki
On Thu, Sep 25, 2008 at 15:39, minh thu [EMAIL PROTECTED] wrote:

 Hi,

 I can't find the loadMatrix function in
 http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/Graphics-Rendering-OpenGL-GL-CoordTrans.html

 Should I use loadIdentity then multMatrix instead ?

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

From what I can see in the source, loadMatrix is method of class
MatrixComponent [1]:

instance MatrixComponent GLfloat_ where
   getMatrix = getFloatv
   loadMatrix = glLoadMatrixf
   loadTransposeMatrix = glLoadTransposeMatrixfARB
   multMatrix_ = glMultMatrixf
   multTransposeMatrix = glMultTransposeMatrixfARB
   rotate a (Vector3 x y z) = glRotatef a x y z
   translate (Vector3 x y z) = glTranslatef x y z
   scale = glScalef

However, for some reason it is not exported:

   MatrixOrder(..), MatrixComponent(rotate,translate,scale), Matrix(..),

Best regards

Christopher Skrzętnicki

[1]: 
http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/src/Graphics-Rendering-OpenGL-GL-CoordTrans.html#MatrixComponent
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: USB and serial port

2008-08-08 Thread Krzysztof Skrzętnicki
Which version do you consider new: the current 0.1.12 or the future
1.0 version?

Regards,
Christopher Skrzętnicki

On Fri, Aug 8, 2008 at 14:54, Maurí­cio [EMAIL PROTECTED] wrote:
 Interesting! The new version of the library
 really deserves a wrapper.

 Thanks,
 Maurício

 I'm currently using partial wrapper around libusb[1] in my work. It
 doesn't provide full interface to the library itself, so I didn't have
 to translate C structures. Perhaps someone can make a regular wrapper
 - the libusb API is pretty small and concise.

 Regards,
 Christopher Skrzętnicki

 [1] http://libusb.wiki.sourceforge.net/

 On Wed, Aug 6, 2008 at 23:11, Maurí­cio [EMAIL PROTECTED] wrote:

 Hi,

 What are the alternatives to read
 a USB port(...)

 ___
 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] USB and serial port

2008-08-07 Thread Krzysztof Skrzętnicki
I'm currently using partial wrapper around libusb[1] in my work. It
doesn't provide full interface to the library itself, so I didn't have
to translate C structures. Perhaps someone can make a regular wrapper
- the libusb API is pretty small and concise.

Regards,
Christopher Skrzętnicki

[1] http://libusb.wiki.sourceforge.net/

On Wed, Aug 6, 2008 at 23:11, Maurí­cio [EMAIL PROTECTED] wrote:
 Hi,

 What are the alternatives to read
 a USB port (actually, a COM serial
 port with an USB adapter) in
 Haskell, running in Linux?

 Thanks,
 Maurício

 ___
 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] Exceptions

2008-07-27 Thread Krzysztof Skrzętnicki
I don't really think this is possible: consider asynchronous
exceptions and throwTo.

http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#v%3AthrowTo

Since it can throw just *any* exception into thread. And this thread
might not be aware that anyone can throw him anything. Therefore it is
not possible to catch it while compiling it's code.

But Maybe I'm Just wrong.

Christopher Skrzętnicki

2008/7/27 Adrian Neumann [EMAIL PROTECTED]:
 Hello,

 I think it'd be nice if the compiler could warn me if there are any
 exceptions which I'm not catching, similar to checked exceptions in Java.
 Does anyone know of a possibility to do that in Haskell?

 Adrian

 ___
 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] Libevent FFI problems

2008-07-25 Thread Krzysztof Skrzętnicki
2008/7/25 Levi Greenspan [EMAIL PROTECTED]:
 And to not require a permanent thread for each I would
 like to use something like select in C or Selector in Java. I haven't
 found something like this in Haskell, hence the libevent wrapper.
As far as I know GHC's scheduler uses select() internally.
At least it was using at the time of writing this paper:

Developing a high-performance web server in Concurrent Haskell
http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf (see page 15)

Perhaps you might be interested in this paper also because of its topic.


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


Re: Re[2]: [Haskell-cafe] ansi2html - one program, several issues

2008-07-20 Thread Krzysztof Skrzętnicki
On Sun, Jul 20, 2008 at 7:25 AM, Chaddaï Fouché [EMAIL PROTECTED]
wrote:


  That's exactly what I thought. But even if I remove the only 'try' I use
 the
  memory consumption remains unchanged:

 It's true, but in your case your output is almost the raw input data,
 which means that even without a noxious try, you still have the
 whole file in memory. Well hopefully not with your latest code, which
 I would really like to see.


Here is the part that actually changed:

---
split c str = let (p,ps) = aux str in (p:ps)
where
  aux [] = ([],[])
  aux (x:cs) = let (xs,xss) = aux cs in
   if x == c then ([c],(xs:xss)) else ((x:xs),xss)

splitPred :: (Eq a) = (a - Bool) - [a] - [[a]]
splitPred pr str = let (p,ps) = aux str in (p:ps)
where
  aux [] = ([],[])
  aux (x:cs) = let (xs,xss) = aux cs in
   if pr x then ([],((x:xs):xss)) else ((x:xs),xss)

doOneFile :: String - IO ()
doOneFile fname = do
  t1 - getCurrentTime
  doesFileExist (fname ++ .html) = \b - if b then hPutStrLn stderr $
printf File already processed, skipping: %s fname else do
src - readFile fname
out - openFile (fname ++ .html) WriteMode
hSetBuffering out (BlockBuffering (Just 64000))
hPutStrLn out html
hPutStrLn out body bgcolor=\black\
hPutStrLn out meta http-equiv=\Content-Type\ content=\text/html;
charset=UTF-8\
hPutStrLn out span style=\font-family: monospace; font-size: 13;\
span
let extractData = \p - case p of
  Right x - x
  Left err - (trace . show $ err) []
let srcSplit = splitPred (`elem`\n) src
let parsed = concatMap (extractData . parse mainParser fname) srcSplit
execStateT (hPrintHtml (St id)) (out,emptyStyle) -- wypisujemy pierwszy
wiersz
execStateT (mapM_ hPrintHtml parsed) (out,emptyStyle)
hPutStrLn out /span/span
hPutStrLn out /body
hPutStrLn out /html
t2 - getCurrentTime
hPutStrLn stderr $ printf File %s processed. It took %s. File size was
%d characters. fname (show $ diffUTCTime t2 t1) (length src)
hClose out
--

The whole file is also attached. You will find there another (worse)
implementation of split and a little bit of code similar to thread pool
stuff.

On Sun, Jul 20, 2008 at 8:17 AM, John Meacham [EMAIL PROTECTED] wrote:

 On Sun, Jul 20, 2008 at 02:34:09AM +0400, Bulat Ziganshin wrote:
  i think that Parsec library should hold entire file in memory only when
  you use 'try' for whole file. otherwise it should omit data as
  proceeded

 I do not believe that is the case, since the return type of runParser
 Either ParseError a means that before you can extract the result of
 the parse from the 'Right' branch, it must evaluate whether the result
 is 'Left' or 'Right' meaning it needs to parse the whole input in order
 to determine whether the parse was succesful.


It's true it has to parse the whole file, but it is not true it has to
reside in the memory: only the results must be there. In this case, when the
result is 1-1 transformation of input, it is true. But consider this
program:

module Main where
import Text.ParserCombinators.Parsec

par = eof | (char 'a'  par)

alst = take 2 (repeat 'a')

main = print (runParser par ()  alst)

It runs in constant memory:

$ ./partest.exe +RTS -sstderr
C:\cygwin\home\Metharius\killer\killerPy\ansi2html\partest.exe +RTS -sstderr
Right ()
  84,326,845,636 bytes allocated in the heap
  22,428,536 bytes copied during GC
   9,684 bytes maximum residency (1 sample(s))
  13,848 bytes maximum slop
   1 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0: 160845 collections, 0 parallel,  0.63s,  0.63s elapsed
  Generation 1: 1 collections, 0 parallel,  0.00s,  0.00s elapsed

  INIT  time0.02s  (  0.00s elapsed)
  MUT   time   54.31s  ( 54.55s elapsed)
  GCtime0.63s  (  0.63s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time   54.95s  ( 55.17s elapsed)

  %GC time   1.1%  (1.1% elapsed)

  Alloc rate1,552,176,623 bytes per MUT second

  Productivity  98.8% of total user, 98.4% of total elapsed


Best regards
Christopher Skrzętnicki


ansi2html.hs
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] ansi2html - one program, several issues

2008-07-20 Thread Krzysztof Skrzętnicki
I played with another approach without any parser library, just with plain
pattern matching. The idea was to create function to match all different
cases of codes. Since I already got most of the code, it was quite easy to
do. The core function consist of cases like those:

  parse ('\ESC':'[':'1':';':'4':'0':'m':rest) = modifyAndPrint (\x - x
{ bgcol = light black }) parse rest
  parse ('\ESC':'[':'1':';':'4':'1':'m':rest) = modifyAndPrint (\x - x
{ bgcol = light red }) parse rest
  parse ('\ESC':'[':'1':';':'4':'2':'m':rest) = modifyAndPrint (\x - x
{ bgcol = light green }) parse rest
  parse ('\ESC':'[':'1':';':'4':'3':'m':rest) = modifyAndPrint (\x - x
{ bgcol = light yellow }) parse rest

If you have read the old code you should recognize some parts of it here.
It should consume rather constant amount of memory. To my surprise it
consumed almost exactly the same amount of memory as the previous program.
Turns out the problematic line was this:

hPutStrLn stderr $ printf File %s processed. It took %s. File size was
%d characters. fname (show $ diffUTCTime t2 t1) *(length src)*

It computed length of the input file. Needless to say, because src was
actually the input file parsed previously, it was all hanging in the memory.
Having removed that reference to src both programs (the one that parses
input per line and the most recent one) are running in constant memory
(2Mb). This doesn't apply to the first program, which has to read whole file
before producing any output.

And the last note: the new program is also 2x faster, perhaps due to very
simple structure that is easy to optimize. It also makes sense now to use
mapMPar as it reduces run time by 30%. The full code is in attachments.

Best regards
Christopher Skrzętnicki


ansi2html.hs
Description: Binary data


ansi2html.hs
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ansi2html - one program, several issues

2008-07-19 Thread Krzysztof Skrzętnicki
I forgot to mention that the memory consumption is several times higher than
file size. On 8,3 Mb file:
 532 MB total memory in use (4 MB lost due to fragmentation).

Having that 8 Mb in memory is not the problem. 532 Mb is another story. In
general, the program consumes roughly 64 times more memory than file size
and it scales linearly.


Best regards
Christopher Skrzętnicki

On Sat, Jul 19, 2008 at 9:52 PM, Chaddaï Fouché [EMAIL PROTECTED]
wrote:

 2008/7/19 Krzysztof Skrzętnicki [EMAIL PROTECTED]:
  Hi all
 
  1) Profiling shows that very simple functions are source of great memory
 and
  time consumption. However, if I turn them off and simply print their
 input
  arguments instead, the overall time and memory consumption doesn't
 change.
  But now another function is acting badly. My guess: somehow the cost of
  Parsec code is shifted into whatever function is using it's output. Let's
  see:

 Are you using Parsec to parse the whole file ? Then your problem is
 there : Parsec needs to read and process the whole file before it can
 give us any output since it thinks it could have to give us an error
 instead and it can't be sure of that before he has read the whole
 thing...
 In your case, your problem is such that you would prefer to treat the
 file as a stream, isn't it ?
 There are some parser library that can give output lazily (look at
 polyparse flavour), another option would be to only use Parsec where
 you need it and just read and print the ordinary text for example.

 --
 Jedaï

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


Re: [Haskell-cafe] ansi2html - one program, several issues

2008-07-19 Thread Krzysztof Skrzętnicki
On Sat, Jul 19, 2008 at 11:35 PM, Chaddaï Fouché [EMAIL PROTECTED]
wrote:

 2008/7/19 Krzysztof Skrzętnicki [EMAIL PROTECTED]:
  I forgot to mention that the memory consumption is several times higher
 than
  file size. On 8,3 Mb file:
  532 MB total memory in use (4 MB lost due to fragmentation).
 
  Having that 8 Mb in memory is not the problem. 532 Mb is another story.
 In
  general, the program consumes roughly 64 times more memory than file size
  and it scales linearly.

 You should be using ByteString, though this problem would be
 alleviated if you were consuming the file as a stream.


Since ANSI color codes doesn't contain characters like newline or space, I
have simply split input file into such lines. Now the whole program behaves
much better: GC time is below 10% and memory consumption dropped to 74 Mb
per thread. It's still a lot of memory though and it certainly holds much
more than one line of text.

Best regards
Christopher Skrzętnicki
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] ansi2html - one program, several issues

2008-07-19 Thread Krzysztof Skrzętnicki
On Sun, Jul 20, 2008 at 12:34 AM, Bulat Ziganshin [EMAIL PROTECTED]
wrote:

 Hello Krzysztof,

 Sunday, July 20, 2008, 1:55:45 AM, you wrote:
  532 MB total memory in use (4 MB lost due to fragmentation).

 i think that Parsec library should hold entire file in memory only when
 you use 'try' for whole file. otherwise it should omit data as
 proceeded


That's exactly what I thought. But even if I remove the only 'try' I use the
memory consumption remains unchanged:

C:\cygwin\home\Metharius\killer\KillerPy\ansi2html\ansi2html_old.exe
duzy.log +RTS -sstderr
File duzy.log processed. It took 5.046875s. File size was 4166578
characters.
   3,950,649,704 bytes allocated in the heap
 535,544,056 bytes copied during GC
 117,603,408 bytes maximum residency (9 sample(s))
   1,647,828 bytes maximum slop
 265 MB total memory in use (2 MB lost due to fragmentation)

  Generation 0:  7527 collections, 0 parallel,  0.86s,  0.86s elapsed
  Generation 1: 9 collections, 0 parallel,  0.80s,  0.81s elapsed

  INIT  time0.02s  (  0.00s elapsed)
  MUT   time3.20s  (  3.63s elapsed)
  GCtime1.66s  (  1.67s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time4.88s  (  5.30s elapsed)

  %GC time  34.0%  (31.6% elapsed)

  Alloc rate1,227,386,315 bytes per MUT second

  Productivity  65.7% of total user, 60.5% of total elapsed



One more thing to note: with partial parsing there is no longer a difference
between mapM_ and mapMPar.

Best regards
Christopher Skrzętnicki
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What's the difference?

2008-04-08 Thread Krzysztof Skrzętnicki
On Tue, Apr 8, 2008 at 11:05 PM, PR Stanley [EMAIL PROTECTED] wrote:


 
   What is the difference between
  
  data T0 f a = MkT0 a
  instance Eq (T0 f a) where ...
  
  and
  
  data T0 f a = MkT0 a
  instance Eq a = Eq (T0 f a) where ...
  
  The second one says that TO f a is only an instance of Eq if a is,
 while the first says that TO f a is an instance regardless of the type of
 its arguments.
 
 
  More explanation please. :-)


Well, it's similar with functions. If we try:

foo :: a - a - Bool
foo x y = x  y

We'll get an error: the usage of `` requires `a` to be in Ord class,
which we write down as type signature:

foo :: (Ord a) = a - a - Bool

The similar effect is for type classes. Here:
 instance Eq a = Eq (T0 f a) where ...
We can see that we can compare elements of type `a` for equality. It's
kind of saying: if you give me an element of type `a`, and that type
is in Eq class, I can tell you how to tell equality of elements of
type T0 f a.


Regards
Christopher Skrzętnicki
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Shouldn't this loop indefinitely = take (last [0..]) [0..]

2008-04-04 Thread Krzysztof Skrzętnicki
On Fri, Apr 4, 2008 at 7:14 PM, Jake Mcarthur [EMAIL PROTECTED] wrote:
 On Apr 4, 2008, at 11:31 AM, Loup Vaillant wrote:

  I mean, could we calculate this equality without reducing
  length ys to weak head normal form (and then to plain normal form)?
 

  Yes. Suppose equality over Nat is defined something like:

 Z   == Z   = True
 S x == S y = x == y
 x   == y   = False

  And also suppose the length function actually returns a Nat instead of an
 Int. Now the expression reduces as:

 length xs == length ys
 S (length xs') == S (length ys')
 Z == S (length ys'')
 False

  That would not be possible without lazy Nats.

One thing to notice is that with lazy Nats this code:

length [] == length [1..]

would terminate, while on 64 bit platform it is almost bottom :-)
Theoretically it is even worse:

genericLength [] == genericLength [1..] :: Integer

will never terminate and eat infinite amount of memory along the way,  while

genericLength [] == genericLength [1..] :: Nat

will do just fine.

We can however write function like this:

eqLengths [] [] = True
eqLengths (x:xs) (y:ys) = eqLengths ys xs
eqLengths _ _ = False

which looks just fine for me.



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


Re: [Haskell-cafe] Type constraints for class instances

2008-03-23 Thread Krzysztof Skrzętnicki
I fixed the code, see below. In fact, it works now for any listst of
type (YOrd a) = [a]. It works for things like
 ysort [[1..],[1..],[2..],[1..]]
Unfortunately, the performance of ysort is rather low. I belive that
it is impossible to create any sorting algorithm that uses ycmp
instead of compare, that is faster than O(n^2). In fact, ysort is
Theta(n^2), and it appears to be optimal. Why?
Well, consider the bubble sort algorithm. Then ycmp will be simply
sort of swap used there:

ycmp x y = case x `compare` y of
 LT - (x,y)
 EQ - (x,y)
 GT - (y,x)

And because it is the only possible operation here, it can't be
faster. (Though I may be wrong.)

Best regards,


Christopher Skrzętnicki.


---

--- http://hpaste.org/6536#a1

{-# OPTIONS_GHC -O2 #-}

module Data.YOrd (ysort, YOrd(..)) where

-- Well defined where Eq means equality, not only equivalence

class YOrd a where
ycmp :: a - a - (a,a)

instance (Ord a) = YOrd [a] where
ycmp = ycmpWith compare
where
  ycmpWith _ xs [] = ([],xs)
  ycmpWith _ [] xs = ([],xs)
  ycmpWith cmp (xs'@(x:xs)) (ys'@(y:ys)) = case x `cmp` y of
 LT - (xs',ys')
 GT - (ys',xs')
 EQ - let (sm,gt)
= xs `ycmp` ys in
   (x:sm,x:gt)
-- assumes that cmp is equality not equivalence relation here!


ycmpWrap cmp x y = case x `cmp` y of
 LT - (x,y)
 EQ - (x,y)
 GT - (y,x)


instance YOrd Integer where
ycmp = ycmpWrap compare
instance YOrd Char where
ycmp = ycmpWrap compare
instance YOrd Int where
ycmp = ycmpWrap compare


-- ysort : sorting in O(n^2)

ysort :: (YOrd a) = [a] - [a]

ysort = head . mergeAll . wrap

wrap xs = map (:[]) xs

mergeAll [] = []
mergeAll [x] = [x]
mergeAll (a:b:rest) = mergeAll ((merge a b) : (mergeAll rest))

merge xs [] = xs
merge [] xs = xs
merge (x:xs) (y:ys) = let (sm,gt) = x `ycmp` y in
  sm : (merge [gt] $ merge xs ys)




2008/3/21 Stephen Marsh [EMAIL PROTECTED]:
 Actually, infinite trees wouldn't work, for a similar reason to above. You
 can't decide sort order on the infinite left branches, so you could never
 choose the correct right branch.

 Stephen

  2008/3/21 Stephen Marsh [EMAIL PROTECTED]:


  There is a bug in the code:
 
  *Main ycmp [5,2] [2,5] :: ([Int], [Int])
  ([2,2],[5,5])
 
  I think it is impossible to define a working (YOrd a) = YOrd [a]
 instance. Consider:
 
  let (a, b) = ycmp [[1..], [2..]] [[1..],[1..]]
 
  head (b !! 1) -- would be nice if it was 2, but it is in fact _|_
 
  We take forever to decide if [1..] is greater or less than [1..], so can
 never decide if [1..] or [2..] comes next.
 
  However Ord a = YOrd [a] can be made to work, and that is absolutely
 awesome, esp. once you start thinking about things like Ord a = YOrd
 (InfiniteTree a). This really is very cool, Krzysztof.
 
  Stephen
 
 
  2008/3/20 Krzysztof Skrzętnicki [EMAIL PROTECTED]:
 
  
  
  
   Hello everyone,
  
   I'm working on a small module for comparing things incomparable with
 Ord.
   More precisely I want to be able to compare equal infinite lists like
 [1..].
   Obviously
  
   (1) compare [1..] [1..] = _|_
  
   It is perfectly reasonable for Ord to behave this way.
   Hovever, it doesn't have to be just this way. Consider this class
  
   class YOrd a where
  ycmp :: a - a - (a,a)
  
   In a way, it tells a limited version of ordering, since there is no
   way to get `==` out of this.
   Still it can be useful when Ord fails. Consider this code:
  
   (2) sort [ [1..], [2..], [3..] ]
  
   It is ok, because compare can decide between any elements in finite
 time.
   However, this one
  
   (3) sort [ [1..], [1..] ]
  
   will fail because of (1). Compare is simply unable to tell that two
   infinite list are equivalent.
   I solved this by producing partial results while comparing lists. If
   we compare lists
   (1:xs)
   (1:ys)
   we may not be able to tell xs  ys, but we do can tell that 1 will be
   the first element of both of smaller and greater one.
   You can see this idea in the code below.
  
  
   --- cut here ---
  
   {-# OPTIONS_GHC -O2 #-}
  
   module Data.YOrd where
  
   -- Well defined where Eq means equality, not only equivalence
  
   class YOrd a where
  ycmp :: a - a - (a,a)
  
  
   instance (YOrd a) = YOrd [a] where
  ycmp [] [] = ([],[])
  ycmp xs [] = ([],xs)
  ycmp [] xs = ([],xs)
  ycmp xs'@(x:xs) ys'@(y:ys) = let (sm,gt) = x `ycmp` y in
   let (smS,gtS) = xs `ycmp` ys in
   (sm:smS, gt:gtS)
  
  
   ycmpWrap x y = case x `compare` y of
   LT - (x,y)
   GT - (y,x)
   EQ - (x,y) -- biased - but we have to make

Re: [Haskell-cafe] Type constraints for class instances

2008-03-21 Thread Krzysztof Skrzętnicki
It compiles, but it doesn't work when i try to use it on lists. There
are some bugs in that code, but I need some time to fix it.

2008/3/21 Bas van Dijk [EMAIL PROTECTED]:
 2008/3/21 Krzysztof Skrzętnicki [EMAIL PROTECTED]:
...

   I'd like to write the following code:
  
instance (Ord a) = YOrd a where
   ycmp x y = case x `compare` y of
LT - (x,y)
GT - (y,x)
EQ - (x,y)
  
But i get an error Undecidable instances for any type [a].
Does anyone know the way to solve this?

  The module compiles fine when you add the following pragma's to your module:

  {-# LANGUAGE FlexibleInstances #-}
  {-# LANGUAGE UndecidableInstances #-}

  See:
  
 http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#instance-rules
  
 http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#undecidable-instances

  regards,

  Bas

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


[Haskell-cafe] Type constraints for class instances

2008-03-20 Thread Krzysztof Skrzętnicki
Hello everyone,

I'm working on a small module for comparing things incomparable with Ord.
More precisely I want to be able to compare equal infinite lists like [1..].
Obviously

(1) compare [1..] [1..] = _|_

It is perfectly reasonable for Ord to behave this way.
Hovever, it doesn't have to be just this way. Consider this class

class YOrd a where
ycmp :: a - a - (a,a)

In a way, it tells a limited version of ordering, since there is no
way to get `==` out of this.
Still it can be useful when Ord fails. Consider this code:

(2) sort [ [1..], [2..], [3..] ]

It is ok, because compare can decide between any elements in finite time.
However, this one

(3) sort [ [1..], [1..] ]

will fail because of (1). Compare is simply unable to tell that two
infinite list are equivalent.
I solved this by producing partial results while comparing lists. If
we compare lists
(1:xs)
(1:ys)
we may not be able to tell xs  ys, but we do can tell that 1 will be
the first element of both of smaller and greater one.
You can see this idea in the code below.


--- cut here ---

{-# OPTIONS_GHC -O2 #-}

module Data.YOrd where

-- Well defined where Eq means equality, not only equivalence

class YOrd a where
ycmp :: a - a - (a,a)


instance (YOrd a) = YOrd [a] where
ycmp [] [] = ([],[])
ycmp xs [] = ([],xs)
ycmp [] xs = ([],xs)
ycmp xs'@(x:xs) ys'@(y:ys) = let (sm,gt) = x `ycmp` y in
 let (smS,gtS) = xs `ycmp` ys in
 (sm:smS, gt:gtS)


ycmpWrap x y = case x `compare` y of
 LT - (x,y)
 GT - (y,x)
 EQ - (x,y) -- biased - but we have to make our minds!

-- ugly, see the problem below
instance YOrd Int where
ycmp = ycmpWrap
instance YOrd Char where
ycmp = ycmpWrap
instance YOrd Integer where
ycmp = ycmpWrap


-- ysort : sort of mergesort

ysort :: (YOrd a) = [a] - [a]

ysort = head . mergeAll . wrap

wrap :: [a] - [[a]]
wrap xs = map (:[]) xs


mergeAll :: (YOrd a) = [[a]] - [[a]]
mergeAll [] = []
mergeAll [x] = [x]
mergeAll (a:b:rest) = mergeAll ((merge a b) : (mergeAll rest))


merge :: (YOrd a) = [a] - [a] - [a]
merge [] [] = []
merge xs [] = xs
merge [] xs = xs
merge (x:xs) (y:ys) = let (sm,gt) = x `ycmp` y in
  sm : (merge [gt] $ merge xs ys)

--- cut here ---

I'd like to write the following code:

instance (Ord a) = YOrd a where
ycmp x y = case x `compare` y of
 LT - (x,y)
 GT - (y,x)
 EQ - (x,y)


But i get an error Undecidable instances for any type [a].
Does anyone know the way to solve this?


Best regards

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


[Haskell-cafe] YOrd and ysort

2008-03-20 Thread Krzysztof Skrzętnicki
The ysort function I've written for YOrd class was incredibly
inefficient. Here is better one:

ysort :: (YOrd a) = [a] - [a]

ysort = head . mergeAll . wrap

wrap :: [a] - [[a]]
wrap xs = map (:[]) xs


mergeAll :: (YOrd a) = [[a]] - [[a]]
mergeAll [] = []
mergeAll [x] = [x]
mergeAll (a:b:rest) = mergeAll ((merge a b) : (mergeAll rest))


merge :: (YOrd a) = [a] - [a] - [a]
merge [] [] = []
merge xs [] = xs
merge [] xs = xs
merge xs ys = let ((sm:smS),gts) = xs `ycmp` ys in
  smS `seq` gts `seq` sm : (merge smS gts)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: (flawed?) benchmark : sort

2008-03-12 Thread Krzysztof Skrzętnicki
In OCaml you have sort and fastsort - the latter doesn't have to be stable.
It currently is, because fastsort = sort.
I think it is a good thing to leave people an option, if there is something
important to choose.

On Thu, Mar 13, 2008 at 12:48 AM, [EMAIL PROTECTED] wrote:

 G'day all.

 Adrian Hey wrote:

  This might be a reasonable thing to say about *sortBy*, but not sort
  as the ordering of equal elements should not be observable (for any
  correct instance of Ord). It should be impossible to implement a
  function which can discriminate between [a,a],[a,b],[b,a],[b,b] if
  compare a b = EQ.

 Nonsense.  Consider a Schwartzian transform wrapper:

 data OrdWrap k v = OrdWrap k v

 instance (Ord k) = Ord (OrdWrap k v) where
 compare (OrdWrap k1 v1) (OrdWrap k2 v2) = OrdWrap k1 k2

 It would be incorrect (and not sane) for sort [a,b] to return [a,a] in
 this case, though a case could be made that either [a,b] or [b,a] make
 sense.

 Quoting Jules Bean [EMAIL PROTECTED]:

  Stability is a nice property. I don't understand why you are arguing
  against this so aggressiviely.

 Stability is an occasionally very useful property.  However, if there
 is a tradeoff between stability and performance, I'd prefer it if the
 library didn't choose for me.

 Cheers,
 Andrew Bromage
 ___
 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] Re: (flawed?) benchmark : sort

2008-03-11 Thread Krzysztof Skrzętnicki
Are you really sure that your results are correct? I obviously did all my
tests with -O2 on.
Please rerun your tests on the new framework. Also note that this one
contains tests for three cases:
- sorted
- revsorted
- randomized
From previous results I can guess that with randomized input Yhc's code will
be ~3 times slower then the fastest quicksort out there.
But I'm not going to run O(n^2) algorithm to compare with O(n log n) - and
this is the case for (rev?)sorted inputs.


Christopher Skrzętnicki

On Tue, Mar 11, 2008 at 5:14 AM, Richard A. O'Keefe [EMAIL PROTECTED]
wrote:


 On 11 Mar 2008, at 12:27 pm, Krzysztof Skrzętnicki wrote:

  I've written little framework to work on. See sortbench.hs and
  sortbench.py attachments.
  Furthermore, I checked Yhc's implementation of sort: it is indeed
  very fast:

 I took his earlier code and plugged yhc's sort into it.
 Compiling with ghc -O2 using GHC 6.8.2, I found the yhc code (basically
 variant of natural merge) to be considerably slower than some of the
 alternatives.
 (...)
 When I run Krzystztof's test harness (which I have currently brought
 up to
 25 different sorting functions) with a list of the form [1..N] instead
 of
 a random list, suddenly all the variants of merge sort come out ahead of
 all the variants of quick sort.  In fact his best version of quicksort,
 qsort_iv, comes out fully 1155 times slower than the YHC algorithm on a
 list of 10,000 ordered integers.  That can be improved by spending a bit
 of effort on choosing a good pivot, but then the quicksort algorithms
 are
 no longer so competitive for randomised inputs.


This paper looks interesting, I'm going to implement those tests.


 The classic Engineering a Quicksort paper by Bentley and McIlroy from
 Software : Practice  Experience recommends a whole bunch of
 distribution
 shapes (one run, two runs, sawtooth, organ pipes, random, ...) that
 should
 be benchmarked before drawing too many conclusions.


This is the right point. A further work will be to add different input
generators to run them too.


 It is also wise to try more than one data type.  How do the different
 algorithms compare on random samples from a Scrabble dictionary?  (Why
 that particular question?  Because I mean to try it.)

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


  1   2   >