[Haskell-cafe] Iteratee, parsec co.

2010-02-09 Thread Maciej Piechotka
I read a lot about iteratee IO and it seemed very interesting
(Unfortunately it lacks tutorial). Especially features like 'no input
yet' in network programming (with lazy IO + parsec I run into problems
as it tried to evaluate the first response character before sending
output).

I decided first write a simple program and then attempt write a Stream
implementation for parsec.

 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 import Data.Iteratee
 import Text.Parse
 
 data Buffer a = Buffer
 instance Monad m = Stream (Buffer a) (IterateeG [] a m) a where
 uncons Buffer = IterateeG loop
 where loop (Chunk []) =
   return $! Cont (IterateeG loop) Nothing
   loop (Chunk (x:xs)) =
   return $! Done (Just (x, Buffer))
  (Chunk xs)
   loop (EOF Nothing)  =
   return $! Done Nothing (EOF Nothing)
   loop (EOF (Just e)) =
   return $! throwErr e

1. I'm not quite sure what Cursor was suppose to do from A Parsing
Trifecta presentation.

2. Is there any package which contains this stream definition?

3. Why Seek FileOffset is error message?

Regards

PS. I guess iteratee does qualify as cafe but if beginner would be more
appropriate group then I'm sorry - I'll remember next time.


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] various dependencies breakages

2010-02-09 Thread Thomas Girod
Hi there.

I'm trying to reinstall gitit after updating to ghc 6.12 and it's
driving me crazy. I hope you will be able to help me troubleshoot this
mess ...  I'm starting from scratch again, using cabal. I will
post more problems as they appears.

$ cabal install gitit
Resolving dependencies...
cabal: cannot configure datetime-0.2. It requires QuickCheck ==2.*
For the dependency on QuickCheck ==2.* there are these packages:
QuickCheck-2.1, QuickCheck-2.1.0.1, QuickCheck-2.1.0.2 and
QuickCheck-2.1.0.3.
However none of them are available.
QuickCheck-2.1 was excluded because happstack-util-0.4.1 requires
QuickCheck
2
QuickCheck-2.1.0.1 was excluded because happstack-util-0.4.1 requires
QuickCheck 2
QuickCheck-2.1.0.2 was excluded because happstack-util-0.4.1 requires
QuickCheck 2
QuickCheck-2.1.0.3 was excluded because happstack-util-0.4.1 requires
QuickCheck 2

Can't cabal handle several versions of the same library in parallel ? If
not, how can I solve this problem ?

cheers

tom

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


Re: [Haskell-cafe] various dependencies breakages

2010-02-09 Thread Max Bolingbroke
Cabal can handle multiple versions of libraries, but you need to find
a consistent set of libraries when building any one executable, since
they are all going to be linked together. In this case Cabal has
apparently failed to find such a set.

You might be able to get this to work with cabal instal gitit
--constraint='datetime==0.1', since that version only demands
QuickCheck  1.2, and gitit doesn't specify a datetime version. I
haven't tried this though.

Happstack-util should probably not depend on QuickCheck at all if the
tests flag is False -- this appears to be an omission in their Cabal
file 
(http://hackage.haskell.org/packages/archive/happstack-util/0.4.1/happstack-util.cabal).
The datetime package doesn't appear to make this a configurable
dependency at all...

Cheers,
Max

On 9 February 2010 10:40, Thomas Girod tho...@0xc29.net wrote:
 Hi there.

 I'm trying to reinstall gitit after updating to ghc 6.12 and it's
 driving me crazy. I hope you will be able to help me troubleshoot this
 mess ...  I'm starting from scratch again, using cabal. I will
 post more problems as they appears.

 $ cabal install gitit
 Resolving dependencies...
 cabal: cannot configure datetime-0.2. It requires QuickCheck ==2.*
 For the dependency on QuickCheck ==2.* there are these packages:
 QuickCheck-2.1, QuickCheck-2.1.0.1, QuickCheck-2.1.0.2 and
 QuickCheck-2.1.0.3.
 However none of them are available.
 QuickCheck-2.1 was excluded because happstack-util-0.4.1 requires
 QuickCheck
 2
 QuickCheck-2.1.0.1 was excluded because happstack-util-0.4.1 requires
 QuickCheck 2
 QuickCheck-2.1.0.2 was excluded because happstack-util-0.4.1 requires
 QuickCheck 2
 QuickCheck-2.1.0.3 was excluded because happstack-util-0.4.1 requires
 QuickCheck 2

 Can't cabal handle several versions of the same library in parallel ? If
 not, how can I solve this problem ?

 cheers

 tom

 ___
 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] Compiling on Windows - using a particular Manifest file

2010-02-09 Thread Bulat Ziganshin
Hello Günther,

Tuesday, February 9, 2010, 4:03:48 AM, you wrote:

 how can I make ghc use a particular manifest file for embedding? (on
 Windows)

compile.cmd:
windres.exe -I. Register.rc res.o
g++.exe Register.cpp res.o

Register.rc:
1   24  Register.exe.manifest


windres is standard mingw tool


alternatively:

mt.exe -manifest Register64.exe.manifest -outputresource:Register64.exe

where mt.exe is MSVS tool (probably available in free MSVS Express)


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] Iteratee, parsec co.

2010-02-09 Thread Daniel Fischer
Am Dienstag 09 Februar 2010 10:03:46 schrieb Maciej Piechotka:

Sorry, I haven't looked at iteratees at all, so I can't answer your 
questions.

 PS. I guess iteratee does qualify as cafe but if beginner would be more
 appropriate group then I'm sorry - I'll remember next time.

It's not that one kind of question is for the beginners list and only more 
advanced questions are to be posted in the cafe, the distinction is

- the beginners list is lower traffic, so your questions are less likely to 
be overlooked there (though it's unlikely to be overlooked in the cafe 
either)
- questions on beginners are less likely to get answers involving terms 
like zygohistomorphic prepromorphism

So it's more a decision of what kind of answer do you want where to post 
your question.
Another aspect is that your question and the answers are more visible on 
beginners (especially to beginners), so if you think your question is 
something many beginners would wrestle with, that's a reason to post it on 
beginners (or both lists), so other beginners may profit more from it.

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


[Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Hello Cafe,

I tried to generate memory-efficient list of random numbers, so I've
used uvector library for this task. But it doesn't work,
it still allocates more than 6Gb of memory for the random list of 10
million elements. Here is the code:

 import Text.Printf
 import System.Random
 import Control.Applicative
 import System.Environment
 import Data.Array.Vector

 randomListU :: (Int, Int) - StdGen - Int - (UArr Int)
 randomListU b g size = unfoldU size gen g
   where gen g = let (x, g') = randomR b g
 in JustS (x :*: g')

 main = do
   [size] - map read $ getArgs
   let ints = randomListU (-10, 10) (mkStdGen 1) size
   printf %d\n  (sumU ints)

Could someone give a hint, how to implement this function in constant
memory space?

Thank you in advance.

Best regards,
Vasyl Pasternak
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] various dependencies breakages

2010-02-09 Thread Thomas Girod
thanks Lars and Max. It did the trick, except for one small detail : 

MissingH needs the testpack -any dependency, but cabal does not
install it automatically.

tom

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


Re: [Haskell-cafe] Lazy language on JVM/CLR

2010-02-09 Thread Tom Lokhorst
About a year ago, Jeroen Leeuwenstein and I worked on CLR backend for
the Utrecht Haskell Compiler (UHC) [1].
That was a one-month project for a seminar at Utrecht University, and
the backend is far from being complete. But we did make some
interesting observations.

A particular caveat of the UHC is that it does whole program analysis,
so we had access to the entire program and all libraries at compile
time.

A benefit of using the CLR was that it does support tail calls. So a
mutual recursive function definition can loop a million times without
creating a stack overflow.

Our main problem (in efficiency) was lazy evaluation, not knowing the
difference between an evaluated `int` and a possible thunk
`Lazyint`. That meant we had to wrap _everything_ in a layer of
indirection, e.g.:

 add :: Int - Int - Int
 add x y = x + y

 add 2 4

Becomes something equivalent to:

 public int add(Lazyint x, Lazyint y)
 {
   return x.Force() + y.Force();
 }

 add(new Lazy(() = 2), new Lazy(() = 4));

Having a strictness analyser would have helped tremendously.

Also, I wonder if there is some efficient way of implementing the Lazy
class, perhaps by having the Force method using runtime code
generation to override itself. I don't know if this is possible, but I
vaguely remember the Dynamic Language Runtime on .NET doing something
like that.

I find this an interesting topic, so when you do have something more,
please let us know on this list.

- Tom Lokhorst

[1]: http://tom.lokhorst.eu/ehc/clr/ehc-clr-handout.pdf


On Tue, Feb 9, 2010 at 1:42 AM, Tony Morris tonymor...@gmail.com wrote:
 I have hypothesised a pure, lazy language on the JVM and perhaps the
 .NET CLR with FFI to .NET/Java libraries. I foresee various problems but
 none that are catastrophic; just often requiring a compromises,
 sometimes very unattractive compromises. I have authored several
 libraries in the same vain as pure, lazy programming to run on the JVM
 in Java and Scala programming languages.

 I expect others have forethought and perhaps even experimented with such
 a language. Are there any dangers to be wary of that undo the entire
 endeavour?

 Thanks for any insights.

 --
 Tony Morris
 http://tmorris.net/

 ___
 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] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak:
 Hello Cafe,

 I tried to generate memory-efficient list of random numbers, so I've
 used uvector library for this task. But it doesn't work,
 it still allocates more than 6Gb of memory for the random list of 10

 million elements. Here is the code:

Hmm,

$ ghc -O2 --make ranVec
[1 of 1] Compiling Main ( ranVec.hs, ranVec.o )
Linking ranVec ...
$ ./ranVec 1000 +RTS -sstderr
5130
   4,919,912,080 bytes allocated in the heap
 883,256 bytes copied during GC
  26,896 bytes maximum residency (1 sample(s))
  25,620 bytes maximum slop
   1 MB total memory in use (0 MB lost due to fragmentation)

maximum residency is just eight bytes more than for 100,000 or 1,000,000 
numbers. I think that is constant space.

The ~5 GB total allocation is sequential, ten million new StdGens are 
produced and allocated, then immediately garbage collected. I see no 
problem (except that StdGen is slow, e.g. the Mersenne twister is much 
faster [and allocates less, but still linear in size]).

  import Text.Printf
  import System.Random
  import Control.Applicative
  import System.Environment
  import Data.Array.Vector
 
  randomListU :: (Int, Int) - StdGen - Int - (UArr Int)
  randomListU b g size = unfoldU size gen g
where gen g = let (x, g') = randomR b g
  in JustS (x :*: g')
 
  main = do
[size] - map read $ getArgs
let ints = randomListU (-10, 10) (mkStdGen 1) size
printf %d\n  (sumU ints)

 Could someone give a hint, how to implement this function in constant
 memory space?

 Thank you in advance.

 Best regards,
 Vasyl Pasternak

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


[Haskell-cafe] Re: haskelldb in-memory driver?

2010-02-09 Thread Günther Schmidt

Hello Johannes,

no, sorry, HaskellDB is only meant for RDBM back ends, it eventually 
generates SQL (Strings).


I tried to create an EDSL for relational algebra in the finally tagless 
style. This would theoretically allow to create entirely abstract 
expressions which could then be evaluated to either SQL or in-memory 
code or whatever.
Of course I don't even know how to get started and at the moment it's on 
the very top of my wish-list because I really need it badly.
All my code eventually turned into spaghetti code and without being able 
to express the algorithm abstractly(but correctly) and decide on 
implementation later I don't think will even try to untangle my mess, 
because at least it works.


Günther


Am 07.02.10 16:44, schrieb Johannes Waldmann:

Is there a haskelldb-driver that works with a datasource
that is in memory, as a Haskell object?
(like LINQ can work on C# collections) - J.





___
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: haskelldb in-memory driver?

2010-02-09 Thread Colin Paul Adams
 Günther == Günther Schmidt gue.schm...@web.de writes:

Günther Hello Johannes, no, sorry, HaskellDB is only meant for RDBM
Günther back ends, it eventually generates SQL (Strings).

I recall that there WAS an experimental in-memory backend. 
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Lazy language on JVM/CLR

2010-02-09 Thread Sittampalam, Ganesh
Tom Lokhorst wrote:

 Also, I wonder if there is some efficient way of implementing the
 Lazy class, perhaps by having the Force method using runtime code
 generation to override itself. I don't know if this is possible, but
 I vaguely remember the Dynamic Language Runtime on .NET doing
 something like that.

.NET 4 (final release due in the next few months) will have a built-in
lazy type.

Ganesh

=== 
 Please access the attached hyperlink for an important electronic 
communications disclaimer: 
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
 
=== 
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Using Cabal during development

2010-02-09 Thread Limestraël

Cabal/cabal-install are good tools for distribution and installation, but I
was wondering -- as I was starting to learn how to use Cabal -- how do
usually Haskell developpers build their softwares (and especially medium or
big libraries) while they are still developping them ?
With cabal-install, by doing one 'cabal configure' once and 'cabal build'
each time they have altered their code ?
With only Cabal, through some 'runhaskell Setup.hs build's ?

The point is that I am currently writing a binding for an SDL-like library
called SFML. My project is now 55-file wide (and I will have to add some
more), uses hsc2hs and has a little executable (for testing purposes) in
which I add some code each time I add functionnalities to my binding. What I
mean is that it would be a pain to have to compile it by hand whenever I add
something to my code. Currently, I compile it by using a simple shell
script, but it's a little bit lousy, I think.
-- 
View this message in context: 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27515446.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Miguel Mitrofanov

With cabal-install, usually.

Limestraël wrote:
Cabal/cabal-install are good tools for distribution and installation, 
but I was wondering -- as I was starting to learn how to use Cabal -- 
how do usually Haskell developpers build their softwares (and especially 
medium or big libraries) while they are *still developping them* ? With 
cabal-install, by doing one 'cabal configure' once and 'cabal build' 
each time they have altered their code ? With only Cabal, through some 
'runhaskell Setup.hs build's ? The point is that I am currently writing 
a binding for an SDL-like library called SFML. My project is now 55-file 
wide (and I will have to add some more), uses hsc2hs and has a little 
executable (for testing purposes) in which I add some code each time I 
add functionnalities to my binding. What I mean is that it would be a 
pain to have to compile it by hand whenever I add something to my code. 
Currently, I compile it by using a simple shell script, but it's a 
little bit lousy, I think.


View this message in context: Using Cabal during development 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27515446.html
Sent from the Haskell - Haskell-Cafe mailing list archive 
http://old.nabble.com/Haskell---Haskell-Cafe-f13132.html at Nabble.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] Using Cabal during development

2010-02-09 Thread Limestraël

(This is a same message, but with newlines. Sorry for the double post)

Cabal/cabal-install are good tools for distribution and installation, but I
was wondering -- as I was starting to learn how to use Cabal -- how do
usually Haskell developpers build their softwares (and especially medium or
big libraries) while they are still developping them ?
With cabal-install, by doing one 'cabal configure' once and 'cabal build'
each time they have altered their code ?
With only Cabal, through some 'runhaskell Setup.hs build's ?

The point is that I am currently writing a binding for an SDL-like library
called SFML. My project is now 55-file wide (and I will have to add some
more), uses hsc2hs and has a little executable (for testing purposes) in
which I add some code each time I add functionnalities to my binding. What I
mean is that it would be a pain to have to compile it by hand whenever I add
something to my code. Currently, I compile it by using a simple shell
script, but it's a little bit lousy, I think.
-- 
View this message in context: 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27515487.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Iteratee, parsec co.

2010-02-09 Thread Edward Kmett
On Tue, Feb 9, 2010 at 4:03 AM, Maciej Piechotka uzytkown...@gmail.comwrote:

 I read a lot about iteratee IO and it seemed very interesting
 (Unfortunately it lacks tutorial). Especially features like 'no input
 yet' in network programming (with lazy IO + parsec I run into problems
 as it tried to evaluate the first response character before sending
 output).

 I decided first write a simple program and then attempt write a Stream
 implementation for parsec.

  {-# LANGUAGE FlexibleInstances #-}
  {-# LANGUAGE MultiParamTypeClasses #-}
  import Data.Iteratee
  import Text.Parse
 
  data Buffer a = Buffer
  instance Monad m = Stream (Buffer a) (IterateeG [] a m) a where
  uncons Buffer = IterateeG loop
  where loop (Chunk []) =
return $! Cont (IterateeG loop) Nothing
loop (Chunk (x:xs)) =
return $! Done (Just (x, Buffer))
   (Chunk xs)
loop (EOF Nothing)  =
return $! Done Nothing (EOF Nothing)
loop (EOF (Just e)) =
return $! throwErr e

 1. I'm not quite sure what Cursor was suppose to do from A Parsing
 Trifecta presentation.


Note that my parsing trifecta Iteratee differs from the iteratees defined by
Oleg et al; it has access to the entire input so far (accumulated in a
fingertree). The Cursor is the index into that finger tree, and is tracked
as the 'remaining input' by Parsec, allowing backtracking. The presentation
up to that point centers on the changes necessary to Iteratee to make this
possible.

2. Is there any package which contains this stream definition?


Not that I'm aware of, but I hardly qualify as an expert in the mainline
Iteratee implementation.

3. Why Seek FileOffset is error message?


I'm not quite sure what you're asking here.

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


Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Sorry, maybe I should ask more clearer.

I've looked at dons article Haskell as fast as C[1], and tried to
implement similar algorithm but for list of random numbers.

Please look at code:

 import Text.Printf
 import Control.Applicative
 import System.Environment
 import Data.Array.Vector

 main = do
   [size] - map read $ getArgs
   let ints = enumFromToU 0 size :: UArr Int
   printf %d\n  (sumU ints)

This code runs in constant space (on my pc ~25kb allocates on the
heap) regardless of array size. So I tried to achieve similar with
random list, just to replace `enumFromToU` with my own list generator.

So the question - is it possible to implement random list similary to
enumFromToU?


[1]http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working-at-a-high-altitude-for-low-level-performance/

Thank you,
Vasyl Pasternak

2010/2/9 Daniel Fischer daniel.is.fisc...@web.de:
 Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak:
 Hello Cafe,

 I tried to generate memory-efficient list of random numbers, so I've
 used uvector library for this task. But it doesn't work,
 it still allocates more than 6Gb of memory for the random list of 10

 million elements. Here is the code:

 Hmm,

 $ ghc -O2 --make ranVec
 [1 of 1] Compiling Main             ( ranVec.hs, ranVec.o )
 Linking ranVec ...
 $ ./ranVec 1000 +RTS -sstderr
 5130
   4,919,912,080 bytes allocated in the heap
         883,256 bytes copied during GC
          26,896 bytes maximum residency (1 sample(s))
          25,620 bytes maximum slop
               1 MB total memory in use (0 MB lost due to fragmentation)

 maximum residency is just eight bytes more than for 100,000 or 1,000,000
 numbers. I think that is constant space.

 The ~5 GB total allocation is sequential, ten million new StdGens are
 produced and allocated, then immediately garbage collected. I see no
 problem (except that StdGen is slow, e.g. the Mersenne twister is much
 faster [and allocates less, but still linear in size]).

  import Text.Printf
  import System.Random
  import Control.Applicative
  import System.Environment
  import Data.Array.Vector
 
  randomListU :: (Int, Int) - StdGen - Int - (UArr Int)
  randomListU b g size = unfoldU size gen g
    where gen g = let (x, g') = randomR b g
                  in JustS (x :*: g')
 
  main = do
    [size] - map read $ getArgs
    let ints = randomListU (-10, 10) (mkStdGen 1) size
    printf %d\n  (sumU ints)

 Could someone give a hint, how to implement this function in constant
 memory space?

 Thank you in advance.

 Best regards,
 Vasyl Pasternak


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


[Haskell-cafe] Re: haskelldb in-memory driver?

2010-02-09 Thread Günther Schmidt

Hello,

for completeness there is also CoddFish, which is not based on 
HaskellDB, but rather on Oleg's HList.


Günther


Am 09.02.10 14:33, schrieb Colin Paul Adams:

Günther == Günther Schmidtgue.schm...@web.de  writes:


 Günther  Hello Johannes, no, sorry, HaskellDB is only meant for RDBM
 Günther  back ends, it eventually generates SQL (Strings).

I recall that there WAS an experimental in-memory backend.




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


Re: [Haskell-cafe] haskelldb in-memory driver?

2010-02-09 Thread Ivan Panachev
On Sun, Feb 7, 2010 at 6:44 PM, Johannes Waldmann 
waldm...@imn.htwk-leipzig.de wrote:

 Is there a haskelldb-driver that works with a datasource
 that is in memory, as a Haskell object?
 (like LINQ can work on C# collections) - J.


SQLite could make it, take a look at http://www.sqlite.org/inmemorydb.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Ketil Malde
Limestraël limestr...@gmail.com writes:

 how do usually Haskell developpers build their softwares (and
 especially medium or big libraries) while they are still developping them ?
 With cabal-install, by doing one 'cabal configure' once and 'cabal build'
 each time they have altered their code ?
 With only Cabal, through some 'runhaskell Setup.hs build's ?

Generally, the first thing I do is hit C-c C-l in Emacs to load the
current file into a haskell process.  Then back to fix the type errors
(click on the error to jump to the code), and iterate until it loads
correctly. 

Then I can play with expressions in the Haskell buffer until I'm
satisfied things work as expected.  Now I can use darcsum to record the
changes.

For libraries, I switch to an xterm to do the ./Setup.hs build; sudo
./Setup.hs install routine.  I guess I could be using cabal-install for
this, but I haven't really gotten around to installing it everywhere
yet.

For binaries, I sometimes build executables using ghc --make in the
shell, using -optl-static -oplt-pthread to build static executables for
distribution to different machines.

This process could probably be improved, but that's how it stands at the
moment.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Limestraël

Okay, so then I have so troubles regarding the compilation of my executable:

First, what do you think is the simpler : (1) build only the library through
cabal-install and then the executable with ghc (it isn't to be distributed
with the lib), or (2) add both to my 
http://old.nabble.com/file/p27515830/HSFML.cabal .cabal file  and build them
in the same time with a 'cabal build' ?

Because I've tried both methods, and have had issues with both :
(1) after a 'cabal build', ghc doesn't know where to find my library --
whereas cabal-install displays 'Registering HSFL-1.5...' at the end of the
build -- when I do 'ghc --make main.hs'. I'm not gonna do a 'cabal install'
whenever I alter my code, am I?

(2) well, then, when building, if I don't specify that my executable depends
on my lib, I got:
SFML/Direct/Graphics.hs:51:7:
Could not find module `SFML.Direct.Types.Enums':
  It is a member of the hidden package `HSFML-1.5'.
  Perhaps you need to add `HSFML' to the build-depends in your .cabal
file.
  it is a hidden module in the package `HSFML-1.5'
  Use -v to see a list of the files searched for.

and if I do what I asks me to add (I add the line 'Build-Depends:  HSFML' in
the 'Executable' section of my .cabal file), I'm told when 'cabal build'ing:
cabal: internal error: could not construct a valid install plan.
The proposed (invalid) plan contained the following problems:
The following packages are involved in a dependency cycle HSFML-1.5



Miguel Mitrofanov wrote:
 
 With cabal-install, usually.
 

-- 
View this message in context: 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27515830.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Lazy language on JVM/CLR

2010-02-09 Thread Tim Wawrzynczak
Perhaps this is similar to what you're looking for.

http://openquark.org/Open_Quark/Welcome.html

It's a pure, lazy language for the JVM.  I haven't used it myself, but I
would imagine that
it would have a Java FFI.

Cheers,
 - Tim

On Mon, Feb 8, 2010 at 6:42 PM, Tony Morris tonymor...@gmail.com wrote:

 I have hypothesised a pure, lazy language on the JVM and perhaps the
 .NET CLR with FFI to .NET/Java libraries. I foresee various problems but
 none that are catastrophic; just often requiring a compromises,
 sometimes very unattractive compromises. I have authored several
 libraries in the same vain as pure, lazy programming to run on the JVM
 in Java and Scala programming languages.

 I expect others have forethought and perhaps even experimented with such
 a language. Are there any dangers to be wary of that undo the entire
 endeavour?

 Thanks for any insights.

 --
 Tony Morris
 http://tmorris.net/

 ___
 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] Lazy language on JVM/CLR

2010-02-09 Thread Edward Kmett
On Mon, Feb 8, 2010 at 8:16 PM, John Meacham j...@repetae.net wrote:


  I expect others have forethought and perhaps even experimented with such
  a language. Are there any dangers to be wary of that undo the entire
  endeavour?

 There have been a couple papers published on it, the main sticking point
 seems to be tail call elimination. When targeting real hardware you
 always had the option of dropping to assembly to do a direct jump, but
 there isn't an equivalent in the JVM. If you look up tail call + jvm you
 will probably get a few hits. I believe there are even a couple haskell
 specific papers on the issue.


One of the easiest approaches to this comes from the scheme folks and I've
been able to employ it fairly effectively in toy compilers. It doesn't
require anything from the host language except exceptions and you can use it
to evaluate spineless tagless g-machine frames mostly on the native/VM stack
fairly easily. The biggest problem is the generated code bloat factor of
about 2-3x.

http://www.ccs.neu.edu/scheme/pubs/stackhack4.html
http://www.cs.brown.edu/~sk/Publications/Papers/Published/pcmkf-cont-from-gen-stack-insp/

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


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Limestraël

Okay, I juste solved issue (1) :

The package compiled through Cabal has its information stored in the
dist/package.conf.inplace file.
I can then compile my main by doing :
ghc --make -package-conf dist/package.conf.inplace main.hs
I just don't know if it's really the way I'm supposed to do this.

Nevertheless, issue (2) remains...



Limestraël wrote:
 
 Okay, so then I have some troubles regarding the compilation of my
 executable:
 
 First, what do you think is the simpler : (1) build only the library
 through cabal-install and then the executable with ghc (it isn't to be
 distributed with the lib), or (2) add both to my 
 http://old.nabble.com/file/p27515830/HSFML.cabal .cabal file  and build
 them in the same time with a 'cabal build' ?
 
 Because I've tried both methods, and have had issues with both :
 (1) after a 'cabal build', ghc doesn't know where to find my library --
 whereas cabal-install displays 'Registering HSFL-1.5...' at the end of the
 build -- when I do 'ghc --make main.hs'. I'm not gonna do a 'cabal
 install' whenever I alter my code, am I?
 
 (2) well, then, when building, if I don't specify that my executable
 depends on my lib, I got:
 SFML/Direct/Graphics.hs:51:7:
 Could not find module `SFML.Direct.Types.Enums':
   It is a member of the hidden package `HSFML-1.5'.
   Perhaps you need to add `HSFML' to the build-depends in your .cabal
 file.
   it is a hidden module in the package `HSFML-1.5'
   Use -v to see a list of the files searched for.
 
 and if I do what it asks me to do (to add the line 'Build-Depends:  HSFML'
 in the 'Executable' section of my .cabal file), I'm told when 'cabal
 build'ing:
 cabal: internal error: could not construct a valid install plan.
 The proposed (invalid) plan contained the following problems:
 The following packages are involved in a dependency cycle HSFML-1.5
 
 
 
 Miguel Mitrofanov wrote:
 
 With cabal-install, usually.
 
 
 

-- 
View this message in context: 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27516610.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Iteratee, parsec co.

2010-02-09 Thread Valery V. Vorotyntsev
| 3. Why Seek FileOffset is error message?

Are you talking about John Lato's implementation [1]?

Well, `Seek' is not an error message. It is one of constructors for
ErrMsg, and ErrMsg is [2]

 ---- a message to the stream producer (e.g., to rewind the stream)
 --   or an error indication.

You know the overall idea behind Seek, don't you?  It is an instrument
to implement random IO [3].


Compare Oleg's code [4]

 data SeekException = SeekException FileOffset
   deriving Show

 instance Typeable SeekException where
 typeOf _ = mkTyConApp (mkTyCon SeekException) []

 instance Exception SeekException

and [2]

 type ErrMsg = SomeException
 data Stream el = EOF (Maybe ErrMsg) | Chunk [el] deriving Show

with John Lato's implementation [1]:

 data StreamG c el =
   EOF (Maybe ErrMsg)
   | Chunk (c el)

 data ErrMsg = Err String
   | Seek FileOffset
   deriving (Show, Eq)

John makes Err and Seek to be the distinct constructors of ErrMsg.
Errors (Err) in `iteratee' package are always Strings.

Oleg's ErrMsg is SomeException.  One of its instances (SeekException)
is a ``rewind the stream'' message to the stream producer. And the user
is free to have as many different ErrMsg'es as he needs to do the job.

  [1] http://inmachina.net/~jwlato/haskell/iteratee/src/Data/Iteratee/Base.hs
  [2] http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs
  [3] http://okmij.org/ftp/Streams.html#random-bin-IO
  [4] http://okmij.org/ftp/Haskell/Iteratee/RandomIO.hs

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


Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Dienstag 09 Februar 2010 14:51:31 schrieb Vasyl Pasternak:
 Sorry, maybe I should ask more clearer.

 I've looked at dons article Haskell as fast as C[1], and tried to
 implement similar algorithm but for list of random numbers.

 Please look at code:
  import Text.Printf
  import Control.Applicative
  import System.Environment
  import Data.Array.Vector
 
  main = do
[size] - map read $ getArgs
let ints = enumFromToU 0 size :: UArr Int
printf %d\n  (sumU ints)

 This code runs in constant space (on my pc ~25kb allocates on the
 heap) regardless of array size.

The random number thing runs in constant space, too.
The difference is that the enumFromToU produces a tight loop with variables 
which never leave the registers, while in the random number thing at least 
the StdGens are allocated in the heap (the produced Ints may stay in the 
registers, too, I don't know).
But enumFromToU and friends were written for that to happen, there are a 
ton of rewrite rules to help the compiler create tight loops. StdGen has no 
such thing, randomR has no {-# INLINE #-} pragma, so you have a call to 
randomR (well, to randomIValInteger, actually) for each element.
Maybe if you had the source for the PRNG in the same file, it could be 
inlined to give an allocation-free loop.

 So I tried to achieve similar with
 random list, just to replace `enumFromToU` with my own list generator.

 So the question - is it possible to implement random list similary to
 enumFromToU?


 [1]http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working-
at-a-high-altitude-for-low-level-performance/

 Thank you,
 Vasyl Pasternak

 2010/2/9 Daniel Fischer daniel.is.fisc...@web.de:
  Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak:
  Hello Cafe,
 
  I tried to generate memory-efficient list of random numbers, so I've
  used uvector library for this task. But it doesn't work,
  it still allocates more than 6Gb of memory for the random list of 10
 
  million elements. Here is the code:
 
  Hmm,
 
  $ ghc -O2 --make ranVec
  [1 of 1] Compiling Main             ( ranVec.hs, ranVec.o )
  Linking ranVec ...
  $ ./ranVec 1000 +RTS -sstderr
  5130
    4,919,912,080 bytes allocated in the heap
          883,256 bytes copied during GC
           26,896 bytes maximum residency (1 sample(s))
           25,620 bytes maximum slop
                1 MB total memory in use (0 MB lost due to
  fragmentation)
 
  maximum residency is just eight bytes more than for 100,000 or
  1,000,000 numbers. I think that is constant space.
 
  The ~5 GB total allocation is sequential, ten million new StdGens are
  produced and allocated, then immediately garbage collected. I see no
  problem (except that StdGen is slow, e.g. the Mersenne twister is much
  faster [and allocates less, but still linear in size]).
 
   import Text.Printf
   import System.Random
   import Control.Applicative
   import System.Environment
   import Data.Array.Vector
  
   randomListU :: (Int, Int) - StdGen - Int - (UArr Int)
   randomListU b g size = unfoldU size gen g
     where gen g = let (x, g') = randomR b g
                   in JustS (x :*: g')
  
   main = do
     [size] - map read $ getArgs
     let ints = randomListU (-10, 10) (mkStdGen 1) size
     printf %d\n  (sumU ints)
 
  Could someone give a hint, how to implement this function in constant
  memory space?
 
  Thank you in advance.
 
  Best regards,
  Vasyl Pasternak

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


Re: [Haskell-cafe] Lazy language on JVM/CLR

2010-02-09 Thread Chris Eidhof
I don't think it's pure. I would definitely use a pure language on the JVM, but 
IIRC Open Quark / Cal is an impure language. For example, from the library 
documentation: printLine :: String - ().

-chris

On 9 feb 2010, at 15:31, Tim Wawrzynczak wrote:

 Perhaps this is similar to what you're looking for.
 
 http://openquark.org/Open_Quark/Welcome.html
 
 It's a pure, lazy language for the JVM.  I haven't used it myself, but I 
 would imagine that 
 it would have a Java FFI.
 
 Cheers,
  - Tim
 
 On Mon, Feb 8, 2010 at 6:42 PM, Tony Morris tonymor...@gmail.com wrote:
 I have hypothesised a pure, lazy language on the JVM and perhaps the
 .NET CLR with FFI to .NET/Java libraries. I foresee various problems but
 none that are catastrophic; just often requiring a compromises,
 sometimes very unattractive compromises. I have authored several
 libraries in the same vain as pure, lazy programming to run on the JVM
 in Java and Scala programming languages.
 
 I expect others have forethought and perhaps even experimented with such
 a language. Are there any dangers to be wary of that undo the entire
 endeavour?
 
 Thanks for any insights.
 
 --
 Tony Morris
 http://tmorris.net/
 
 ___
 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] Lazy language on JVM/CLR

2010-02-09 Thread Tim Wawrzynczak
Oops, you're right.  It's not pure.  Mea cupla for not reading more
closely.  I wonder how it deals with I/O, then?  I don't see anything like
Haskell's monads or Clean's uniqueness typing...  but at a closer look it
does appear to have an excellent Java FFI.

On Tue, Feb 9, 2010 at 9:44 AM, Chris Eidhof ch...@eidhof.nl wrote:

 I don't think it's pure. I would definitely use a pure language on the JVM,
 but IIRC Open Quark / Cal is an impure language. For example, from the
 library documentation: printLine :: String - ().

 -chris

 On 9 feb 2010, at 15:31, Tim Wawrzynczak wrote:

  Perhaps this is similar to what you're looking for.
 
  http://openquark.org/Open_Quark/Welcome.html
 
  It's a pure, lazy language for the JVM.  I haven't used it myself, but I
 would imagine that
  it would have a Java FFI.
 
  Cheers,
   - Tim
 
  On Mon, Feb 8, 2010 at 6:42 PM, Tony Morris tonymor...@gmail.com
 wrote:
  I have hypothesised a pure, lazy language on the JVM and perhaps the
  .NET CLR with FFI to .NET/Java libraries. I foresee various problems but
  none that are catastrophic; just often requiring a compromises,
  sometimes very unattractive compromises. I have authored several
  libraries in the same vain as pure, lazy programming to run on the JVM
  in Java and Scala programming languages.
 
  I expect others have forethought and perhaps even experimented with such
  a language. Are there any dangers to be wary of that undo the entire
  endeavour?
 
  Thanks for any insights.
 
  --
  Tony Morris
  http://tmorris.net/
 
  ___
  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] Using Cabal during development

2010-02-09 Thread Johan Tibell
On Tue, Feb 9, 2010 at 6:10 AM, Ketil Malde ke...@malde.org wrote:

 Limestraël limestr...@gmail.com writes:

  how do usually Haskell developpers build their softwares (and
  especially medium or big libraries) while they are still developping them
 ?
  With cabal-install, by doing one 'cabal configure' once and 'cabal build'
  each time they have altered their code ?
  With only Cabal, through some 'runhaskell Setup.hs build's ?

 Generally, the first thing I do is hit C-c C-l in Emacs to load the
 current file into a haskell process.  Then back to fix the type errors
 (click on the error to jump to the code), and iterate until it loads
 correctly.


It's really unfortunate that this approach doesn't work for .hsc files. When
writing low level libraries I often have a couple of these which forces me
out of my nice Emacs workflow into an Emacs + terminal + Cabal workflow.

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


[Haskell-cafe] Strange Haddock output

2010-02-09 Thread Sean Leather
I was browsing Hackage pointlessly and came across what appears to be
strange Haddock formatting here:

http://hackage.haskell.org/packages/archive/pointless-haskell/0.0.3/doc/html/Generics-Pointless-Functors.html#v%3Afmap

The following source

-- | Polytypic 'Prelude.Functor' class for functor representations
class Functor (f :: * - *) where
  fmap :: Fix f                          -- ^ For desambiguation
purposes, the type of the functor must be passed as an explicit
paramaeter to 'fmap'
       - (x - y) - Rep f x - Rep f y -- ^ The mapping over representations

produces the following view from the browser

class Functor f where
 Polytypic Prelude.Functor class for functor representations
 Methods
   fmap
     ::
     = Fix f
     - x - y
     - Rep f xThe mapping over representations
     - Rep f y

with the Haddock 2.6.0 on Hackage. There seems to be an extraneous =
in the signature of fmap, and the comment on Fix f does not show up.

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


[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14

2010-02-09 Thread John Lato
Edward's reply was quite good.  I'll just try to fill in a few items
he didn't address.

 From: Maciej Piechotka uzytkown...@gmail.com

 I read a lot about iteratee IO and it seemed very interesting
 (Unfortunately it lacks tutorial). Especially features like 'no input
 yet' in network programming (with lazy IO + parsec I run into problems
 as it tried to evaluate the first response character before sending
 output).

 I decided first write a simple program and then attempt write a Stream
 implementation for parsec.

 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 import Data.Iteratee
 import Text.Parse

 data Buffer a = Buffer
 instance Monad m = Stream (Buffer a) (IterateeG [] a m) a where
     uncons Buffer = IterateeG loop
                     where loop (Chunk [])     =
                               return $! Cont (IterateeG loop) Nothing
                           loop (Chunk (x:xs)) =
                               return $! Done (Just (x, Buffer))
                                              (Chunk xs)
                           loop (EOF Nothing)  =
                               return $! Done Nothing (EOF Nothing)
                           loop (EOF (Just e)) =
                               return $! throwErr e


 2. Is there any package which contains this stream definition?

I believe this Stream instance is incorrect. According to the parsec-3.0.1 docs,
A Stream instance is responsible for maintaining the 'position within
the stream' in the stream state s. This is trivial unless you are
using the monad in a non-trivial way.

This is necessary for referential integrity.  That is, uncons s
needs to always evaluate to the same result for the same 's'.  Your
Stream instance doesn't preserve this.  As an example,

 testIter = let b = Buffer in uncons b  uncons b

should be an iteratee that returns a Maybe (t, buffer) where t is
the first element in the enumeration, but with your instance it will
return the second.

See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid
Stream instance using iteratee.  Also Gregory Collins recently posted
an iteratee wrapper for Attoparsec to haskell-cafe.  To my knowledge
these are not yet in any packages, but hackage is vast.


 3. Why Seek FileOffset is error message?

Version 3 of iteratee is somewhat experimental, one of the ideas on
trial is that of resumable exceptions.  This framework is perfectly
suited to handle control messages as well, which is why Seek is
included as an error message.

I don't want to make a major release just to fix this, but both error
handling and control messages will undergo a substantial cleanup in
the next major version.  Included in this will be a proper separation
between control messages and true exceptions, most likely based upon
the extensible-exceptions framework.

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


Re: [Haskell-cafe] various dependencies breakages

2010-02-09 Thread MightyByte
The latest darcs head for happstack has changed the quickcheck
dependency to  2.  You might try that.

On Tue, Feb 9, 2010 at 7:13 AM, Thomas Girod tho...@0xc29.net wrote:
 thanks Lars and Max. It did the trick, except for one small detail :

 MissingH needs the testpack -any dependency, but cabal does not
 install it automatically.

 tom

 ___
 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] Iteratee, parsec co.

2010-02-09 Thread John Lato
 From: Edward Kmett ekm...@gmail.com

 3. Why Seek FileOffset is error message?


 I'm not quite sure what you're asking here.

One of the infelicities of iteratee-0.3 is that it defines a data type:

 data ErrMsg = Err String
   | Seek FileOffset
   deriving (Show, Eq)

I believe this is what the OP is referring to.  Oleg originally
implemented seek using IORefs; I wanted to try this and didn't know if
it would work so I used a minimal implementation.  I've decided this
is the correct approach, but the details need to be tweaked a bit.

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


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Jason Dusek
  My development environment is a Screen with Bash, Vim and GHCi
  running.

  If I can just load the files in GHCi or compile them with GHC
  without specifying many options or extensions, then I just do
  it that way. As soon as I feel a need to write a Makefile or a
  little build script, I write a Cabal file instead and switch
  to using `cabal-install'.

  When I say many options or extensions, I nearly mean any.
  Most projects of mine get a Cabal file at the point where I
  feel the need for the first `LANGUAGE' pragma. (I usually omit
  `LANGUAGE' pragmas, delegating to Cabal for that. I'm not sure
  whether this is good or bad practice.)

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


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Limestraël

Okay, but have you ever felt the need to make in the same project a library
and an executable which depends on this library (even just like me, for
testing purpose)? How would you do it?


Jason Dusek wrote:
 
   My development environment is a Screen with Bash, Vim and GHCi
   running.
 
   If I can just load the files in GHCi or compile them with GHC
   without specifying many options or extensions, then I just do
   it that way. As soon as I feel a need to write a Makefile or a
   little build script, I write a Cabal file instead and switch
   to using `cabal-install'.
 
   When I say many options or extensions, I nearly mean any.
   Most projects of mine get a Cabal file at the point where I
   feel the need for the first `LANGUAGE' pragma. (I usually omit
   `LANGUAGE' pragmas, delegating to Cabal for that. I'm not sure
   whether this is good or bad practice.)
 
 --
 Jason Dusek
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27518960.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] automatically exclude unused modules at compile time

2010-02-09 Thread Hong Yang
I did not use -split-objs.

This option did help after I tried it. Thanks.

Hong

On Mon, Feb 8, 2010 at 11:57 AM, Felipe Lessa felipe.le...@gmail.comwrote:

 On Mon, Feb 08, 2010 at 11:25:13AM -0600, Hong Yang wrote:
  Can we make GHC a little bit more intelligent to automatically exclude
  unused modules at compile time as in case 4)? (Am I just too lazy to add
  several dashes?)

 Did you use -split-objs?  Does it help?

 --
 Felipe.
 ___
 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 Cabal during development

2010-02-09 Thread Jonathan Daugherty
 Cabal/cabal-install are good tools for distribution and
 installation, but I was wondering -- as I was starting to learn how
 to use Cabal -- how do usually Haskell developpers build their
 softwares (and especially medium or big libraries) while they are
 still developping them ?

The first thing I always do is create a skeletal cabal file for my
project and add Library and Executable sections to it.  The executable
might be a test/demo program, or it might be a real app.  I usually
try to put whatever I can into a library to keep my executable source
lightweight.

My development flow relies heavily on some emacs integration with
darcs that I wrote, which allows me to press C-c C-t to run the darcs
test hook preference in am emacs buffer, which happens to be bound to
something like cabal build  some_test_command in most of my
Haskell repositories.  That way I don't usually have to leave my
editor to see the build failures and address them.

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


Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Bryan O'Sullivan
On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak
vasyl.paster...@gmail.comwrote:


 I tried to generate memory-efficient list of random numbers, so I've
 used uvector library for this task.


Use the mwc-random package. It provides a function that does exactly this,
and produces better quality random numbers with much higher performance
(1000x faster) than System.Random or even mersenne-random.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Rahul Kapoor
 Okay, but have you ever felt the need to make in the same project a library
 and an executable which depends on this library (even just like me, for
 testing purpose)? How would you do it?

Specifying the modules under test in other-modules section for the executable
does the trick for me. I can email you a suitable elided cabal file
for one of my projects
if you want.

Also another really helpful thing for testing is adding a .ghci file
in your project
I usually check in the .ghci with my source. Standard commands that I define
in .ghci usually include :test to run the Test Suite. I also use .ghci
set up the correct
source paths and to start up with the test module loaded. So
recompiles are usually
just as simple as :reload.

I still run the complete cabal configure -ftest  cabal configure
build  ./dist//test
before commits.

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


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Limestraël

Then how does the 'Executable' section of your .cabal look like? That's what
I can't get working.


Jonathan Daugherty-4 wrote:
 The first thing I always do is create a skeletal cabal file for my
 project and add Library and Executable sections to it.  The executable
 might be a test/demo program, or it might be a real app.  I usually
 try to put whatever I can into a library to keep my executable source
 lightweight.
-- 
View this message in context: 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27520110.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Rahul Kapoor
 Then how does the 'Executable' section of your .cabal look like? That's what
 I can't get working.

Suitably elided.

Executable test
  hs-source-dirs:   src, tests
  other-modules:Text.Yaml.Yay, Text.Yaml.Yay.Syck
  main-is:  Main.hs
  build-depends:base, HsSyck, syb
 if flag(test)
build-depends:  QuickCheck = 2.1   2.2,
test-framework-quickcheck2 = 0.2   0.3,
test-framework = 0.2   0.3
  else
buildable:  False



Library
  Hs-Source-Dirs:   src
  Exposed-Modules:  Text.Yaml.Yay, Text.Yaml.Yay.Syck
  Other-Modules:Text.Yaml.Yay.Internal.Utils,
Text.Yaml.Yay.Syck.Encoder, Text.Yaml.Yay.Syck.Decoder
  Build-Depends:base, HsSyck, syb
  if flag(test)
-- Faster builds
ghc-options:-O0
  else
-- Optimized builds
ghc-options:-O2
  if flag(nolib)
buildable:  False
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Jonathan Daugherty
 Then how does the 'Executable' section of your .cabal look like?
 That's what I can't get working.

  Executable vty-ui-demo
Hs-Source-Dirs:  src
Main-is: Demo.hs
Build-Depends:
  mtl = 1.1   1.2

The Main-is refers to src/Demo.hs.  This example is from:

  http://hackage.haskell.org/packages/archive/vty-ui/0.2/vty-ui.cabal

The package description link on any Hackage package page will link
to the release's cabal file, so you can see how other folks have
written their Executable sections.

Hope that helps,

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


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Jonathan Daugherty
 Executable test
   hs-source-dirs:   src, tests
   other-modules:Text.Yaml.Yay, Text.Yaml.Yay.Syck
   ...

In general, it's not advisable to name your test executable test due
to a naming collision with the typical test utility.  You might
consider naming it $package_name-test.  (This is also more
cabal-install-friendly.)

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


[Haskell-cafe] Re: Using Cabal during development

2010-02-09 Thread Jose A. Ortega Ruiz
Johan Tibell johan.tib...@gmail.com writes:

 It's really unfortunate that this approach doesn't work for .hsc
 files. When writing low level libraries I often have a couple of these
 which forces me out of my nice Emacs workflow into an Emacs + terminal
 + Cabal workflow.

I use the elisp code below to run cabal without leaving emacs, with its
output going into a compilation buffer (so that one can jump to the
errors). C-c c will find the cabal file nearest to the current buffer
and invoke cabal.

HTH,
jao

--8---cut here---start-8---

(defun jao-locate-dominating-files (regexp optional file)
 Look up the directory hierarchy from FILE for a file matching REGEXP.
 Stop at the first parent where a matching file is found and return the
 list
 of files that that match in this directory.
 (catch 'found
   (let ((dir (file-name-as-directory (or file (buffer-file-name
 files)
 (while (and dir
 (not (string-match locate-dominating-stop-dir-regexp
dir)))
   (if (setq files (condition-case nil
   (directory-files dir 'full regexp 'nosort)
 (error nil)))
   (throw 'found files)
 (if (equal dir
(setq dir (file-name-directory
   (directory-file-name dir
 (setq dir nil
 nil)))

(defun jao-haskell-locate-cabal-file ()
 Find the cabal file associated with current buffer.
 (car (jao-locate-dominating-files .+\\.cabal)))

(eval-after-load 'haskell-mode
 '(add-hook 'haskell-mode-hook
(lambda ()
  (set (make-local-variable 'compile-command) cabal
 build

(defun jao-haskell-cabal-build ()
 Run, in a compilation buffer, a cabal command, after finding
the cabal file associated with this buffer.
 (interactive)
 (let ((cabal-file (jao-haskell-locate-cabal-file)))
   (unless cabal-file
 (error Couldn't find associated cabal file))
   (let ((default-directory (file-name-directory cabal-file)))
 (call-interactively 'compile

(eval-after-load 'haskell-mode
  '(define-key haskell-mode-map [?\C-c ?c] 'jao-haskell-cabal-build))

--8---cut here---end---8---

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


[Haskell-cafe] Re: Strange Haddock output

2010-02-09 Thread David Waern
2010/2/9 Sean Leather leat...@cs.uu.nl:
 I was browsing Hackage pointlessly and came across what appears to be
 strange Haddock formatting here:

 http://hackage.haskell.org/packages/archive/pointless-haskell/0.0.3/doc/html/Generics-Pointless-Functors.html#v%3Afmap

 The following source

 -- | Polytypic 'Prelude.Functor' class for functor representations
 class Functor (f :: * - *) where
   fmap :: Fix f  -- ^ For desambiguation
 purposes, the type of the functor must be passed as an explicit
 paramaeter to 'fmap'
- (x - y) - Rep f x - Rep f y -- ^ The mapping over representations

 produces the following view from the browser

 class Functor f where
  Polytypic Prelude.Functor class for functor representations
  Methods
fmap
  ::
  = Fix f
  - x - y
  - Rep f xThe mapping over representations
  - Rep f y

 with the Haddock 2.6.0 on Hackage. There seems to be an extraneous =
 in the signature of fmap, and the comment on Fix f does not show up.

I think this is an instance of a bug introduced when implementing
cross-package documentation. It has been fixed already and will be in
the next minor release.

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


[Haskell-cafe] Re: Strange Haddock output

2010-02-09 Thread David Waern
 I think this is an instance of a bug introduced when implementing
 cross-package documentation. It has been fixed already and will be in
 the next minor release.

Sorry, I should have said that the /fix/ will be in the next minor
release, and not the bug, of course :-)

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


Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Tuesday 09 February 2010 19:19:18 schrieben Sie:
 Daniel,

 I've just run venum2 program locally and here is my results:

 $ ./venum2 1000 +RTS -s
 ./venum2 1000 +RTS -s
 500500
   22,736 bytes allocated in the heap
  688 bytes copied during GC
   17,184 bytes maximum residency (1 sample(s))
   19,680 bytes maximum slop
1 MB total memory in use (0 MB lost due to fragmentation)

 $ ./venum2 10 +RTS -s
 ./venum2 10 +RTS -s
 55
   24,152 bytes allocated in the heap
  688 bytes copied during GC
   17,184 bytes maximum residency (1 sample(s))
   19,680 bytes maximum slop
1 MB total memory in use (0 MB lost due to fragmentation)

 So my PC shows that there is constant memory allocation. Maybe I'm
 doing something wrong ?

Unlikely.
However, I notice that you seem to have a 64-bit system.
I don't know the details, but usually those have more registers than a 32-
bit system, so you can get more complicated loops to run completely in the 
registers.
I think that's what happens here, enumFromToU' is just complicated enough 
to not run in the registers on my 32-bit system, but still runs in the 
registers on your 64-bit system.

The PRNG code is too complicated (too many temporary variables) to run in 
the registers on either system (BTW, have you tried it with the specialised 
PRNG code in the source file? I'm not sure whether that might be just small 
enough to run in the registers on a 64-bit system.).


 2010/2/9 Daniel Fischer daniel.is.fisc...@web.de:
  Am Tuesday 09 February 2010 15:43:13 schrieben Sie:
  Update:
 
  I've implemented `enumFromToU` through `unfoldU`:
   enumFromToU' from to = unfoldU (to - from) f from
      where f i = let i' = i + 1 in JustS (i' :*: i')
 
  This code behaves similarly to `enumFromToU` (i.e. constantly uses
  ~25 kb of memory, runs in the same time as above).
 
  Wait,
 
  $ cat venum2.hs
  module Main (main) where
 
  import Text.Printf
  import Control.Applicative
  import System.Environment
  import Data.Array.Vector
 
  main = do
    [size] - map read $ getArgs
    let ints = enumFromToU' 0 size :: UArr Int
    printf %d\n  (sumU ints)
 
  enumFromToU' from to = unfoldU (to - from) f from
     where f i = let i' = i + 1 in JustS (i' :*: i')
 
  $ ghc -O2 --make venum2
  [1 of 1] Compiling Main             ( venum2.hs, venum2.o )
  Linking venum2 ...
  $ ./venum2 +RTS -sstderr -RTS 100
  ./venum2 100 +RTS -sstderr
  1784293664
       48,256,384 bytes allocated in the heap
            6,256 bytes copied during GC
           26,804 bytes maximum residency (1 sample(s))
           25,524 bytes maximum slop
                1 MB total memory in use (0 MB lost due to
  fragmentation)
 
  $ ./venum2 +RTS -sstderr -RTS 1000
  ./venum2 1000 +RTS -sstderr
  -2004260032
      481,937,552 bytes allocated in the heap
           19,516 bytes copied during GC
           26,804 bytes maximum residency (1 sample(s))
           25,512 bytes maximum slop
                1 MB total memory in use (0 MB lost due to
  fragmentation)
 
  So we have constant memory, but linear allocation, just like with the
  random numbers.
 
  With enumFromToU, also the allocation is constant, so unfoldU
  allocates, enumFromToU not.
 
  So the question is why random number list generator eats O(n) memory
  ?
 
  It doesn't, not here, at least. Using System.Random, the allocation
  figures are about ten times as high, but the residency is about the
  same. Putting the PRNG code in the same file and tweaking things a bit
  (eliminating all intermediate Integers, e.g.), I get
 
  $ cat ran2Vec.hs
  {-# LANGUAGE BangPatterns #-}
  module Main (main) where
 
  import Text.Printf
  import Control.Applicative
  import System.Environment
  import Data.Array.Vector
 
  randomListU :: (Int, Int) - StdGen - Int - (UArr Int)
  randomListU b@(l,h) g size = unfoldU size gen g
    where
     !k = h-l+1
     !b' = 2147483561 `rem` k
     gen !g = let (!x, !g') = stdNext g
              in JustS ((l+ (x+b') `rem` k) :*: g')
 
  main = do
    [size] - map read $ getArgs
    let ints = randomListU (-10, 10) (mkStdGen 1) size
    printf %d\n  (sumU ints)
 
  data StdGen = StdGen {-# UNPACK #-} !Int {-# UNPACK #-} !Int
 
  mkStdGen :: Int - StdGen
  mkStdGen s
   | s  0     = mkStdGen (-s)
   | otherwise = StdGen (s1+1) (s2+1)
       where
     (q, s1) = s `divMod` 2147483562
     s2      = q `mod` 2147483398
 
  {-# INLINE stdNext #-}
  stdNext :: StdGen - (Int, StdGen)
  -- Returns values in the range stdRange
  stdNext (StdGen s1 s2) = z' `seq` g' `seq` (z', g')
     where
         !g'   = StdGen s1'' s2''
         !z'   = if z  1 then z + 2147483562 else z
         !z    = s1'' - s2''
 
         !k    = s1 `quot` 53668
         !s1'  = 40014 * (s1 - k * 53668) - k * 12211
         !s1'' = if s1'  0 then s1' + 2147483563 else s1'
 
         !k'   = s2 `quot` 

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Dienstag 09 Februar 2010 19:27:58 schrieb Bryan O'Sullivan:
 On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak

 vasyl.paster...@gmail.comwrote:
  I tried to generate memory-efficient list of random numbers, so I've
  used uvector library for this task.

 Use the mwc-random package. It provides a function that does exactly
 this, and produces better quality random numbers with much higher
 performance (1000x faster) than System.Random or even mersenne-random.

Not here.
I may be doing it wrong, but


{-# LANGUAGE BangPatterns #-}
module Main (main) where

import Text.Printf
import System.Random.MWC
import Control.Applicative
import System.Environment
import Data.Array.Vector
import Control.Monad.ST

randomListU :: (Int, Int) - Int - Int -- (UArr Int)
randomListU b@(l,h) size = runST $ do
let !k = h-l+1
f !m = m `mod` k + l
sg - create
sumU . mapU f $ uniformArray sg size

main = do
  [size] - map read $ getArgs
  let int = randomListU (-10, 10) size
  printf %d\n int


gives
$ ghc -O2 -funfolding-use-threshold=32 -fforce-recomp --make mwcRanVec.hs -
o mwcRanVec3
[1 of 1] Compiling Main ( mwcRanVec.hs, mwcRanVec.o )
Linking mwcRanVec3 ...
$ ./mwcRanVec3 +RTS -s -RTS 1000
./mwcRanVec3 1000 +RTS -s
22784
  40,966,820 bytes allocated in the heap
   3,696 bytes copied during GC
  27,128 bytes maximum residency (1 sample(s))
  26,940 bytes maximum slop
  40 MB total memory in use (0 MB lost due to fragmentation)

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

  INIT  time0.00s  (  0.00s elapsed)
  MUT   time1.09s  (  1.15s elapsed)
  GCtime0.00s  (  0.00s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time1.10s  (  1.15s elapsed)

  %GC time   0.0%  (0.0% elapsed)

  Alloc rate37,376,166 bytes per MUT second

  Productivity  99.6% of total user, 95.2% of total elapsed

, System.Random.Mersenne

$ ./mtRanVec +RTS -s -RTS 1000
./mtRanVec 1000 +RTS -s
-24541
 280,609,188 bytes allocated in the heap
  17,404 bytes copied during GC
  26,776 bytes maximum residency (1 sample(s))
  25,724 bytes maximum slop
   1 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0:   535 collections, 0 parallel,  0.00s,  0.00s elapsed
  Generation 1: 1 collections, 0 parallel,  0.00s,  0.00s elapsed

  INIT  time0.00s  (  0.00s elapsed)
  MUT   time1.10s  (  1.10s elapsed)
  GCtime0.00s  (  0.00s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time1.10s  (  1.10s elapsed)

  %GC time   0.4%  (0.4% elapsed)

  Alloc rate255,083,261 bytes per MUT second

  Productivity  99.3% of total user, 99.5% of total elapsed

more or less the same, the System.Random code gives

$ ./uRanVec +RTS -s -RTS 1000./uRanVec 1000 +RTS -s
5130
   4,515,826,700 bytes allocated in the heap
 803,132 bytes copied during GC
  26,852 bytes maximum residency (1 sample(s))
  25,716 bytes maximum slop
   1 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0:  8680 collections, 0 parallel,  0.10s,  0.10s elapsed
  Generation 1: 1 collections, 0 parallel,  0.00s,  0.00s elapsed

  INIT  time0.00s  (  0.00s elapsed)
  MUT   time9.12s  (  9.17s elapsed)
  GCtime0.10s  (  0.10s elapsed)
  EXIT  time0.00s  (  0.00s elapsed)
  Total time9.22s  (  9.27s elapsed)

  %GC time   1.1%  (1.1% elapsed)

  Alloc rate495,342,570 bytes per MUT second

  Productivity  98.9% of total user, 98.3% of total elapsed

(so a factor of a little above 8), and the specialised System.Random code 
in the source file,


{-# LANGUAGE BangPatterns #-}
module Main (main) where

import Text.Printf
import Control.Applicative
import System.Environment
import Data.Array.Vector

randomListU :: (Int, Int) - StdGen - Int - (UArr Int)
randomListU b@(l,h) g size = unfoldU size gen g
  where
!k = h-l+1
!b' = 2147483561 `rem` k
gen !g = let (!x, !g') = stdNext g
 in JustS ((l+ (x+b') `rem` k) :*: g')

main = do
  [size] - map read $ getArgs
  let ints = randomListU (-10, 10) (mkStdGen 1) size
  printf %d\n  (sumU ints)

data StdGen = StdGen {-# UNPACK #-} !Int {-# UNPACK #-} !Int

mkStdGen :: Int - StdGen
mkStdGen s
 | s  0 = mkStdGen (-s)
 | otherwise = StdGen (s1+1) (s2+1)
  where
(q, s1) = s `divMod` 2147483562
s2  = q `mod` 2147483398

{-# INLINE stdNext #-}
stdNext :: StdGen - (Int, StdGen)
-- Returns values in the range stdRange
stdNext (StdGen s1 s2) = z' `seq` g' `seq` (z', g')
where
!g'   = StdGen s1'' s2''
!z'   = if z  1 then z + 2147483562 else z
!z= s1'' - 

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Daniel,

Yes, I have 64 bit system.

Maybe you're right. The PRNG code with the same vector size allocates
two times more memory at my PC. (~ 1 Gb)

Thank you,
Vasyl

2010/2/9 Daniel Fischer daniel.is.fisc...@web.de:
 Am Tuesday 09 February 2010 19:19:18 schrieben Sie:
 Daniel,

 I've just run venum2 program locally and here is my results:

 $ ./venum2 1000 +RTS -s
 ./venum2 1000 +RTS -s
 500500
           22,736 bytes allocated in the heap
              688 bytes copied during GC
           17,184 bytes maximum residency (1 sample(s))
           19,680 bytes maximum slop
                1 MB total memory in use (0 MB lost due to fragmentation)

 $ ./venum2 10 +RTS -s
 ./venum2 10 +RTS -s
 55
           24,152 bytes allocated in the heap
              688 bytes copied during GC
           17,184 bytes maximum residency (1 sample(s))
           19,680 bytes maximum slop
                1 MB total memory in use (0 MB lost due to fragmentation)

 So my PC shows that there is constant memory allocation. Maybe I'm
 doing something wrong ?

 Unlikely.
 However, I notice that you seem to have a 64-bit system.
 I don't know the details, but usually those have more registers than a 32-
 bit system, so you can get more complicated loops to run completely in the
 registers.
 I think that's what happens here, enumFromToU' is just complicated enough
 to not run in the registers on my 32-bit system, but still runs in the
 registers on your 64-bit system.

 The PRNG code is too complicated (too many temporary variables) to run in
 the registers on either system (BTW, have you tried it with the specialised
 PRNG code in the source file? I'm not sure whether that might be just small
 enough to run in the registers on a 64-bit system.).


 2010/2/9 Daniel Fischer daniel.is.fisc...@web.de:
  Am Tuesday 09 February 2010 15:43:13 schrieben Sie:
  Update:
 
  I've implemented `enumFromToU` through `unfoldU`:
   enumFromToU' from to = unfoldU (to - from) f from
      where f i = let i' = i + 1 in JustS (i' :*: i')
 
  This code behaves similarly to `enumFromToU` (i.e. constantly uses
  ~25 kb of memory, runs in the same time as above).
 
  Wait,
 
  $ cat venum2.hs
  module Main (main) where
 
  import Text.Printf
  import Control.Applicative
  import System.Environment
  import Data.Array.Vector
 
  main = do
    [size] - map read $ getArgs
    let ints = enumFromToU' 0 size :: UArr Int
    printf %d\n  (sumU ints)
 
  enumFromToU' from to = unfoldU (to - from) f from
     where f i = let i' = i + 1 in JustS (i' :*: i')
 
  $ ghc -O2 --make venum2
  [1 of 1] Compiling Main             ( venum2.hs, venum2.o )
  Linking venum2 ...
  $ ./venum2 +RTS -sstderr -RTS 100
  ./venum2 100 +RTS -sstderr
  1784293664
       48,256,384 bytes allocated in the heap
            6,256 bytes copied during GC
           26,804 bytes maximum residency (1 sample(s))
           25,524 bytes maximum slop
                1 MB total memory in use (0 MB lost due to
  fragmentation)
 
  $ ./venum2 +RTS -sstderr -RTS 1000
  ./venum2 1000 +RTS -sstderr
  -2004260032
      481,937,552 bytes allocated in the heap
           19,516 bytes copied during GC
           26,804 bytes maximum residency (1 sample(s))
           25,512 bytes maximum slop
                1 MB total memory in use (0 MB lost due to
  fragmentation)
 
  So we have constant memory, but linear allocation, just like with the
  random numbers.
 
  With enumFromToU, also the allocation is constant, so unfoldU
  allocates, enumFromToU not.
 
  So the question is why random number list generator eats O(n) memory
  ?
 
  It doesn't, not here, at least. Using System.Random, the allocation
  figures are about ten times as high, but the residency is about the
  same. Putting the PRNG code in the same file and tweaking things a bit
  (eliminating all intermediate Integers, e.g.), I get
 
  $ cat ran2Vec.hs
  {-# LANGUAGE BangPatterns #-}
  module Main (main) where
 
  import Text.Printf
  import Control.Applicative
  import System.Environment
  import Data.Array.Vector
 
  randomListU :: (Int, Int) - StdGen - Int - (UArr Int)
  randomListU b@(l,h) g size = unfoldU size gen g
    where
     !k = h-l+1
     !b' = 2147483561 `rem` k
     gen !g = let (!x, !g') = stdNext g
              in JustS ((l+ (x+b') `rem` k) :*: g')
 
  main = do
    [size] - map read $ getArgs
    let ints = randomListU (-10, 10) (mkStdGen 1) size
    printf %d\n  (sumU ints)
 
  data StdGen = StdGen {-# UNPACK #-} !Int {-# UNPACK #-} !Int
 
  mkStdGen :: Int - StdGen
  mkStdGen s
   | s  0     = mkStdGen (-s)
   | otherwise = StdGen (s1+1) (s2+1)
       where
     (q, s1) = s `divMod` 2147483562
     s2      = q `mod` 2147483398
 
  {-# INLINE stdNext #-}
  stdNext :: StdGen - (Int, StdGen)
  -- Returns values in the range stdRange
  stdNext (StdGen s1 s2) = z' `seq` g' `seq` (z', g')
     where
         !g'   = StdGen s1'' s2''
         !z'   = if z  1 then z + 

[Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism?

2010-02-09 Thread caseyh



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


Re: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism?

2010-02-09 Thread Eugene Kirpichov
In what exact sense are monads single threaded, and of which exactly
parallelism are you talking about?

2010/2/10  cas...@istar.ca:


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




-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using Cabal during development

2010-02-09 Thread Limestraël

I think I must be dumb or something.
I did my SFML.cabal exactly the way the packager of vty-ui did vty-ui.cabal,
and I still have got the error when building:
hs_src/SFML/Direct/Graphics.hs:51:7:
Could not find module `SFML.Direct.Types.Enums':
  It is a member of the hidden package `SFML-1.5'.
  Perhaps you need to add `SFML' to the build-depends in your .cabal
file.
  it is a hidden module in the package `SFML-1.5'
  Use -v to see a list of the files searched for.

My cabal file is  http://old.nabble.com/file/p27522604/SFML.cabal here . Il
you get to know why it doesn't work, please tell me, because I'm lost...
I have a hs_src directory, which contains an SFML directory (the lib) and a
demo.hs file. (the simple main)
It's the way vty-ui package is done.


Jonathan Daugherty-4 wrote:
 
 Then how does the 'Executable' section of your .cabal look like?
 That's what I can't get working.
 
   Executable vty-ui-demo
 Hs-Source-Dirs:  src
 Main-is: Demo.hs
 Build-Depends:
   mtl = 1.1   1.2
 
 The Main-is refers to src/Demo.hs.  This example is from:
 
   http://hackage.haskell.org/packages/archive/vty-ui/0.2/vty-ui.cabal
 
 The package description link on any Hackage package page will link
 to the release's cabal file, so you can see how other folks have
 written their Executable sections.
 
 Hope that helps,
 
 -- 
   Jonathan Daugherty
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://old.nabble.com/Using-Cabal-during-development-tp27515446p27522604.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism?

2010-02-09 Thread Matthias Görgens
Monads are not commutative.  A structure that would tell the compiler
that it's commutative, would give it more leeway for optimization (and
parallel execution).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Navigating Graphs

2010-02-09 Thread Matthias Görgens
Using something like zippers it is easy to navigate an acyclic graph
in O(1) operations per arc you follow.  Inspired by Chris Okasaki's
work on queues I wondered if there is a similar approach to navigating
cyclic graphs.

If the graph you are navigating is static (i.e. does not have to
support addition or removal of vertices in any reasonable amount of
time), I guess you can get away with Tying the know
(http://www.haskell.org/haskellwiki/Tying_the_Knot).  But is there a
technique that allows navigation, insertion and removal at focus in
(at least amortised) O(1) operations each?

As a generalisation being able to have multiple points of focus (in an
acyclic graph for a start) would also be interesting.

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


Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-09 Thread Jeremy Shaw
On Sun, Feb 7, 2010 at 9:22 AM, Bardur Arantsson s...@scientician.netwrote:

True, it is perhaps technically not a bug, but it is certainly a misfeature
 since there is no easy way (at least AFAICT) to discover that something bad
 has happened for the file descriptor and act accordingly. AFAICT any
 solution would have to be based on a separate thread which either 1)
 checks the FD periodically somehow, or 2) simply lets the thread doing the
 threadWaitWrite time out after a set period of inactivity. Neither is very
 optimal.

 Either way, I'd certainly expect the sendfile library to work around this
 somehow such that this situation doesn't occur. I'm just having a hard time
 thinking up a good solution :).


Well, it is certainly a bug in sendfile that needs to be fixed. I'm not sure
how to fix it either. If we can simplify the test case, we can ask Simon
Marlow..

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


Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Bryan,

mwc-random is really fast. But it eats to much memory. My previous
attempts were to reduce total number of allocations. This package made
this possible, but it increases total memory usage.

Here is the code:

import Text.Printf
import System.Random.MWC
import Control.Applicative
import System.Environment
import Data.Array.Vector
import Control.Monad.ST

randomListU size = runST $ flip uniformArray size = create

main = do
  [size] - map read $ getArgs
  printf %d\n $ (sumU (randomListU size) :: Int)

And sample tests:

./mwcvec 1000 +RTS -s
-9198901858466039191
 165,312 bytes allocated in the heap
 688 bytes copied during GC
  17,184 bytes maximum residency (1 sample(s))
  19,680 bytes maximum slop
  78 MB total memory in use (1 MB lost due to fragmentation)


./mwcvec 1 +RTS -s
2242701120799374676
 165,704 bytes allocated in the heap
 688 bytes copied during GC
  17,184 bytes maximum residency (1 sample(s))
  19,680 bytes maximum slop
 764 MB total memory in use (12 MB lost due to fragmentation)

./mwcvec 10 +RTS -s
mwcvec: out of memory (requested 8000634880 bytes)

I don't know exactly, but is this a normal behavior ?

Thank you,
Vasyl

2010/2/9 Bryan O'Sullivan b...@serpentine.com:
 On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak vasyl.paster...@gmail.com
 wrote:

 I tried to generate memory-efficient list of random numbers, so I've
 used uvector library for this task.

 Use the mwc-random package. It provides a function that does exactly this,
 and produces better quality random numbers with much higher performance
 (1000x faster) than System.Random or even mersenne-random.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Bryan O'Sullivan
On Tue, Feb 9, 2010 at 3:48 PM, Vasyl Pasternak
vasyl.paster...@gmail.comwrote:


 mwc-random is really fast. But it eats to much memory.


It creates and returns a vector, so if you ask it to give you a billion
items, it's going to require north of 8 gigabytes of memory. This should not
come as a surprise, I'd hope :-)  Assuming that's not what you actually
want, you should look at other entry points in the API, which you can use to
generate a single value at a time in constant space.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-09 Thread Thomas Hartman
Matt, have you seen this thread?

Jeremy, are you saying this a bug in the sendfile library on hackage,
or something underlying?

thomas.

2010/2/9 Jeremy Shaw jer...@n-heptane.com:
 On Sun, Feb 7, 2010 at 9:22 AM, Bardur Arantsson s...@scientician.net
 wrote:

 True, it is perhaps technically not a bug, but it is certainly a
 misfeature since there is no easy way (at least AFAICT) to discover that
 something bad has happened for the file descriptor and act accordingly.
 AFAICT any solution would have to be based on a separate thread which either
 1) checks the FD periodically somehow, or 2) simply lets the thread doing
 the threadWaitWrite time out after a set period of inactivity. Neither is
 very optimal.

 Either way, I'd certainly expect the sendfile library to work around this
 somehow such that this situation doesn't occur. I'm just having a hard time
 thinking up a good solution :).

 Well, it is certainly a bug in sendfile that needs to be fixed. I'm not sure
 how to fix it either. If we can simplify the test case, we can ask Simon
 Marlow..
 - jeremy
 ___
 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] Generate random UArray in constant memory space.

2010-02-09 Thread Felipe Lessa
On Tue, Feb 09, 2010 at 04:27:57PM -0800, Bryan O'Sullivan wrote:
 It creates and returns a vector, so if you ask it to give you a billion
 items, it's going to require north of 8 gigabytes of memory. This should not
 come as a surprise, I'd hope :-)  Assuming that's not what you actually
 want, you should look at other entry points in the API, which you can use to
 generate a single value at a time in constant space.

He thought the vector would be fused away by the library, which
is one of the selling points of uvector.  Sadly the
implementation of uniformArray wasn't done with this purpose in
mind.

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


[Haskell-cafe] Jobs

2010-02-09 Thread Roderick Ford

We need two developers at the company I work for; that is, I am NOT a 
recruiter.  My boss is asking me to search for developers for me to work with 
... like minded, haskell loving, driven, c/c++ (c# if we have to) for an 
INITIALLY c# full-time salaried position in Arizona (or FL or UT).  He is open 
to starting new projects using Haskell, where applicable. 

 

So, he is involving me in the interview process, and I've been less than 
pleased with candidate selection so far.  I told him we need to find people 
that see the beauty of mathematics and Haskell.  If you have a resume you want 
me to forward on, reply to me directly and I will forward on through the review 
process.

 

Here is a clip from posting 1 (don't take too literally):

Software Engineer with strong 'Design, Programming, Debugging' experience

Required Experience


3+yrs MS C# *AND* C++
MS SQL Server
MS ASP.NET
MS SQL
Applicants must have at least 3 years practical work experience designing and 
building commercial software products that have shipped on the Windows OS 
platform. 
Requires proven experience building Web GUI on Windows platform, familiarity 
with distributed programming and networking. 
Must also be able to write and debug SQL Stored Procedures. 
Developer will be required to take ownership of the assigned modules through 
design, code  unit test. 
Past team lead experience would be valuable. 
Familiarity with gcc and Linux / Unix programming would be a plus.

4 year degree in a Computer Science related field with at least 5-7 years of 
experience in a software development environment or similar combination of 
education/work experience.


 This position is available in the following offices:


Scottsdale, Arizona
Provo, Utah
Melbourne, Florida
 

 

Here is a clip from posting 2:

 

Job Description

As a Senior C# - Asp.net Software Engineer in this position you will operate 
within a group of engineers, engaged in product design and implementation of 
enterprise applications. This role has a very high level of technical and 
product knowledge spanning multiple development technologies and target 
platforms. The Senior Software Engineer operates unsupervised and is a 
self-starter.

 Essential Duties and Responsibilities:


Performs OOD, implementation and maintenance for products composed with a 
variety of technologies, mostly for Windows platforms but also Linux and other 
platforms
Provides expertise for multiple software layers and levels of abstraction: UI, 
business layer, database, and distributed operations.  
Builds a tactical consensus with the development team whilst demonstrating 
strong technical leadership skills
Experience working in a scrum agile environment a plus
Performs highly complex product design activities which may require extensive 
research and analysis
Performs complex bug verification, release testing and beta support for 
assigned products
Researches problems discovered by QA or product support and identifies 
solutions to the problems
Conducts unit testing and integration testing for functionality and performance 
limits
In absence of product architects, may serve as a product architect
Researches and understands non-functional requirements beyond the marketing 
requirements for a product
Researches new technology or development tools to remain informed of current 
technology
Required Skills

Advanced technical knowledge in software development methodologies, design and 
implementation in C#. Expert analytical and design skills at 
multi-product/multi-environment level.

Understands cross-platform and/or internationalisation development. In-depth 
experience in research and analysis, project planning and implementation. 
Excellent understanding of entire development process, including specification, 
documentation and quality assurance. Aware of business issues as they impact 
overall project plans. Recognised reference and central point for technical 
issues across groups and products. Strong communications and interpersonal 
skills. Advanced PC skills.

Required Experience

A university degree in computer science or software engineering, preferably a 
masters or higher, is desireable. 

Requires 10 to 15 years of experience in product design

Good knowledge of .Net, and ASP.NET, for C# developers.

Minimum 5 Years Experience of C# language and Asp.net
  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lazy language on JVM/CLR

2010-02-09 Thread Tom Davies

On 10/02/2010, at 2:52 AM, Tim Wawrzynczak wrote:

 Oops, you're right.  It's not pure.  Mea cupla for not reading more closely.  
 I wonder how it deals with I/O, then?  I don't see anything like Haskell's 
 monads or Clean's uniqueness typing...  but at a closer look it does appear 
 to have an excellent Java FFI.
 
 On Tue, Feb 9, 2010 at 9:44 AM, Chris Eidhof ch...@eidhof.nl wrote:
 I don't think it's pure. I would definitely use a pure language on the JVM, 
 but IIRC Open Quark / Cal is an impure language. For example, from the 
 library documentation: printLine :: String - ().

CAL is pure as long as you don't call Java functions with side effects, or 
functions like printLine -- rather like avoiding unsafePerformIO in Haskell. 
For my experimentation I use my own IO monad implementation, but you can 
generally use `seq` to control when IO happens.

The Java FFI is good, although arguably verbose.

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


[Haskell-cafe] Re: Category Theory woes

2010-02-09 Thread L Spice
Mark Spezzano mark.spezzano at chariot.net.au writes:

 Does anyone know what Hom stands for?

'Hom' stands for 'homomorphism' --a way of changing (morphism)
between two structures while keeping some information the same (homo-).
Any algebra text will define morphisms aplenty --homomorphisms,
epimorphisms, monomorphisms, and the like.  These are maps on groups
that preserve group operations (or on rings that preserve ring operations,
etc.)

In a topology text, you will find information on what are called
continuous functions; they're morphisms too, in disguise.  You can find a
thinner disguise when you look at continuously invertible continuous
functions, which are called homeomorphisms.  If you proceed to differential
geometry, you'll see smooth maps --they're morphisms too, and the
invertible ones are called diffeomorphisms.

This-morphisms, that-morphisms --if you're trying to come up with a
general theory that describes all of them, it's natural just to call them
'morphisms'; but, as with the word 'colonel', the word and the symbol come to
us via different routes, so that 'Hom(omorphism)' survives instead as the
abbreviation.  The crucial point in learning category theory is the realisation
that, despite all the fancy terminology, it is at heart nothing but a way of
talking about groups, rings, topological spaces, partial orders, etc.
--all at once, so no wonder it seems abstract!

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