[GHC] #1315: System.Process.runInteractiveProcess needs a way to pipe just some handles

2007-05-01 Thread GHC
#1315: System.Process.runInteractiveProcess needs a way to pipe just some 
handles
---+
  Reporter:  simonmar  |  Owner: 
  Type:  task  | Status:  new
  Priority:  normal|  Milestone:  6.8
 Component:  libraries/base|Version:  6.6.1  
  Severity:  normal|   Keywords: 
Difficulty:  Moderate (1 day)  | Os:  Unknown
  Testcase:|   Architecture:  Unknown
---+
Currently `runInteractiveProcess` attaches pipes to all 3 standard
 handles.  Sometimes it's necessary to attach pipes to a subset, and
 possibly pass in existing Handles for the others.  For example this could
 be used to connect a sequence of processes together with pipes.  Also see
 Distribution.Simple.Utils.rawSystemStdout.

 While we're here, we could add a more convenient popen-like API.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1315
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1292: -Wall doesn't include all warnings

2007-05-01 Thread GHC
#1292: -Wall doesn't include all warnings
-+--
Reporter:  guest |Owner: 
Type:  bug   |   Status:  closed 
Priority:  normal|Milestone: 
   Component:  Compiler  |  Version:  6.7
Severity:  normal|   Resolution:  fixed  
Keywords:|   Difficulty:  Unknown
  Os:  Unknown   | Testcase: 
Architecture:  Unknown   |  
-+--
Changes (by simonmar):

  * resolution:  = fixed
  * status:  reopened = closed

Comment:

 Ok, I'm convinced.  `-Wall` would be rather less useful if it really
 included all warnings.  I've updated the documentation to match the
 current behaviour.

 I'm ambivalent about whether `-fwarn-monomorphism-restriction` should be
 in `-Wall`; Simon PJ believes it should be.  That discussion can be moved
 to the mailing list, however.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1292
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


groupBy

2007-05-01 Thread Frederik Eaton
Hello,

My copy of the library documentation says:

groupBy :: (a - a - Bool) - [a] - [[a]]
The groupBy function is the non-overloaded version of group.
User-supplied comparison (replacing an Ord context)
The function is assumed to define a total ordering.

But group has an Eq context. I don't understand how an Ord context
would even be used, or how the function argument of groupBy is meant
to define a total ordering. Is this a typo?

Frederik

-- 
http://ofb.net/~frederik/
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #1316: add warning for local type signatures that use the same type variable names as outer type signatures

2007-05-01 Thread GHC
#1316: add warning for local type signatures that use the same type variable 
names
as outer type signatures
--+-
  Reporter:  Isaac Dupree |  Owner: 
  Type:  feature request  | Status:  new
  Priority:  normal   |  Milestone: 
 Component:  Compiler |Version:  6.6.1  
  Severity:  normal   |   Keywords: 
Difficulty:  Unknown  | Os:  Unknown
  Testcase:   |   Architecture:  Unknown
--+-
for a (poor) example,
 {{{
 f :: a - a
 f x = x
where
  g :: a  --this is (forall x. x) not the 'a' from f's type signature
  -- So, warn about this signature.
  g = undefined
 }}}
 Because it is likely to be confusing, as well as interfering with any
 possibility of the type variables being considered scoped by default.  In
 fact, this may be a helpful/explanatory message in cases where there will
 also be a type error due to the type variables not actually being scoped.
 (although, detecting those cases particularly and giving a recommended
 solution for how to give such a type signature, would be a more difficult
 endeavor (what to recommend?))

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1316
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #1317: add warning for the Prelude being imported implicitly

2007-05-01 Thread GHC
#1317: add warning for the Prelude being imported implicitly
--+-
  Reporter:  Isaac Dupree |  Owner: 
  Type:  feature request  | Status:  new
  Priority:  normal   |  Milestone: 
 Component:  Compiler |Version:  6.6.1  
  Severity:  normal   |   Keywords: 
Difficulty:  Unknown  | Os:  Unknown
  Testcase:   |   Architecture:  Unknown
--+-
For those who don't like the implicit Prelude (but have an existing
 codebase to work with, or want to stay compatible with Haskell standards).
 The only ways to keep the warning from triggering, once enabled, are
 `-fno-implicit-prelude`/`LANGUAGE NoImplicitPrelude`, and/or at least one
 `import ... Prelude ...` line appearing in the module.

 Proposed flag name:  -fwarn-implicit-prelude

 Proposed on status:  not even on with -Wall, must be enabled explicitly

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1317
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #1318: add warning for prefix negate operator and flag to replace it with negative numeric literals

2007-05-01 Thread GHC
#1318: add warning for prefix negate operator and flag to replace it with 
negative
numeric literals
+---
  Reporter:  Isaac Dupree   |  Owner:  Isaac Dupree
  Type:  feature request| Status:  new 
  Priority:  normal |  Milestone:  6.8 
 Component:  Compiler (Parser)  |Version:  6.6.1   
  Severity:  normal |   Keywords:  
Difficulty:  Unknown| Os:  Unknown 
  Testcase: |   Architecture:  Unknown 
+---
This is tracking a few things relating to the notion that Haskell's single
 prefix operator, `-`, should not exist and `-1` should parse as a
 single token anyway.  See
 http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/11954

 If there is a LANGUAGE option for this, what should it be called; and what
 should the ghc flags be called? Should turning off prefix negation and
 turning on negative numeric literals be separately controllable? This sort
 of question (exactly what should be implemented) is probably half the
 difficulty here.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1318
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #1319: grammatical mistake in user's guide description of -fwarn-name-shadowing

2007-05-01 Thread GHC
#1319: grammatical mistake in user's guide description of -fwarn-name-shadowing
+---
  Reporter:  Isaac Dupree   |  Owner: 
  Type:  bug| Status:  new
  Priority:  normal |  Milestone: 
 Component:  Documentation  |Version:  6.6.1  
  Severity:  trivial|   Keywords: 
Difficulty:  Unknown| Os:  Unknown
  Testcase: |   Architecture:  Unknown
+---
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-
 sanity.html

 Consequently, this option does will complain about cyclic recursive
 definitions.

 does will isn't quite right - I think it should just be will

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1319
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1319: grammatical mistake in user's guide description of -fwarn-name-shadowing

2007-05-01 Thread GHC
#1319: grammatical mistake in user's guide description of -fwarn-name-shadowing
--+-
Reporter:  Isaac Dupree   |Owner: 
Type:  bug|   Status:  closed 
Priority:  normal |Milestone: 
   Component:  Documentation  |  Version:  6.6.1  
Severity:  trivial|   Resolution:  fixed  
Keywords: |   Difficulty:  Unknown
  Os:  Unknown| Testcase: 
Architecture:  Unknown|  
--+-
Changes (by [EMAIL PROTECTED]):

  * resolution:  = fixed
  * status:  new = closed

Comment:

 Fixed it.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1319
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: ghc configure

2007-05-01 Thread Simon Marlow

C.M.Brown wrote:


I've noticed that when you run ./configure on a ghc build lot's of
repetition occurs. A lot of the time the same checks are being performed for
each configure file in the ghc hierarchy. Could it be possible if some of
these checks could be done once at a high level and then subsequent
configures could refer to these checks to speed up
configuration time? It's just configuring ghc on a mac G4 is a very time
consuming process in it's own right!


Mainly this is due to modularity: many of the library packages can be built 
entirely separately from GHC, so their configure scripts are designed to be 
standalone.


I know that configure takes a long time on Windows, but I'm surprised if it's a 
bottleneck for other platforms.  How long does the build take?  Have you taken 
steps to speed up the build as described in the Building Guide?


Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ghc configure

2007-05-01 Thread C.M.Brown
Hi Simon,

 Mainly this is due to modularity: many of the library packages can be built
 entirely separately from GHC, so their configure scripts are designed to be
 standalone.


Yes, I guess it would be a fair bit of work to have it check that you are
building the whole of GHC as opposed to separate modules. I just thought
that it could check to see if it was a global build -- and share configure
checks where appropriate; or, in separate module builds the configure runs
as normally.

 I know that configure takes a long time on Windows, but I'm surprised if it's 
 a
 bottleneck for other platforms.  How long does the build take?  Have you taken
 steps to speed up the build as described in the Building Guide?

Configuring and building on my Mac can take several hours. Mind you, it's
a slow machine (G4 1.33 with 1 gig of RAM). I can safely say it's very
fast on my linux machine - the configure whips through, and even a full
build only takes a little more than an hour or so.

Thanks for pointing out tips to speed up the build. I must confess my
ignorance of not checking that!

Kind regards,
Chris.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ghc configure

2007-05-01 Thread Claus Reinke

Mainly this is due to modularity: many of the library packages can be built
entirely separately from GHC, so their configure scripts are designed to be
standalone.


library packages are haskell packages, and much of the configuration data
should be common (plus a few package-specific checks). would it be possible
to have a configuration package with nothing but the common checks? then
every package, and ghc itself, could depend on that package being there, and
every package configure could modularly use the information from that package.

such a package might also encode the information in haskell, for use in cabal?
perhaps creating such common info should be a cabal feature, factoring common
checks from the package configure files to cabal, which would need access to
some shared configuration file to store and retrieve the info? that way, once
you've got cabal built on a platform, there'd be no need to repeat the common
suspects of tests in individual configure files?

just thinking out loud,-)
claus

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


RE: recent Windows installer for ghc head?

2007-05-01 Thread Simon Peyton-Jones
Following the snapshot distribution link on GHC's download page yields this

http://www.haskell.org/ghc/dist/current/dist/ghc-6.7.20070404-i386-unknown-mingw32.tar.bz2

That seems to be a tar bundle for Windows; it's not an msi but if you unpack it 
you should be able to run it just fine.

Simon

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Conal Elliott
Sent: 27 April 2007 20:03
To: glasgow-haskell-users@haskell.org
Subject: recent Windows installer for ghc head?

I'd like to try out the new  improved combination of type classes and GADTs, 
which I understand is only in head.  Is there a recent working windows 
installer for head?

Thanks,  - Conal
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: More speed please!

2007-05-01 Thread Josef Svenningsson

I'm replying to a rather old thread here, about unboxing in functions. Duncan
had a continuation monad which passed around some data type that would be nice
to unbox. You discussed strictness annotations in function types as a potential
solution. I have a different tack on the problem which seems potentially
useful. I've experimented with doing local defunctionalization on the module.
This is a long mail as I will try to explain in some detail what it is that I
have done. Please be patient.

Normal defunctionalization is about replacing the primitive function type
a - b with an algebraic data type which I'll call Fun a b. Not all
functions will be eliminated as we will see but the program will be first
order after the transformation. The core of the transformation is that every
lambda in the program gives rise to a new constructor in the Fun data type and
whenever we apply a function we instead call a newly created apply function
with the following type Fun a b - a - b. This is basically what JHC does.

Defunctionalization is normally a whole program transformation (which is why
JHC is a whole program compiler). But sometimes it can be done on a per module
basis. This is where *local* defunctionalization comes in. The key to local
defunctionalization is that we often can divide the data type Fun into several
disjoint data types. We can do this whenever there are several different
function spaces that never get mixed up. And sometimes we're even so lucky
that a function space is totally contained in one module. Then we can do
local defunctionalization of that particular function space only and
completely within that module without changing it's interface. This case often
comes up when using the continuation monad and Duncan's code is not an
exception.

So, I've manually done local defunctionalization on Duncan's code. It gives
rise to two types which I've called Fun1 and Fun2. They look like follows
(including the Put monad):

\begin{code}
newtype Put a = Put {
   runPut :: Fun2 a
   }

data Fun1 a where
 Bind :: (a - Put b) - Fun1 b - Fun1 a
 Then :: Put b  - Fun1 b - Fun1 a
 Run  :: Fun1 ()
 FlushOld :: !(Fun1 ()) - !Int - !(ForeignPtr Word8) - !Int - !Int
   - Fun1 ()

data Fun2 a where
 Return :: a - Fun2 a
 Bind2  :: Put a - (a - Put b) - Fun2 b
 Then2  :: Put a - Put b - Fun2 b
 Flush  :: Fun2 ()
 Write  :: !Int - (Ptr Word8 - IO ()) - Fun2 ()
\end{code}
Intuitively every constructor corresponds to a closure. I've chosen the name
for the constructor based on which function the closure appears in.

The respective apply functions for these data types acts as interpreters and
executes the corresponding code for each constructor/closure. Their type look
as follow:

\begin{code}
apply1 :: Fun1 a - a - Buffer - [B.ByteString]
apply2 :: Fun2 a - Fun1 a - Buffer - [B.ByteString]
\end{code}

Now, the cool thing is that once GHC starts optimizing away on these apply
functions they will be unboxed and no Buffer will ever be created or passed
around. Here is the core type for apply1:
\begin{core}
$wapply1_r21p :: forall a_aQu.
 PutMonad.Fun1 a_aQu
 - a_aQu
 - GHC.Prim.Addr#
 - GHC.ForeignPtr.ForeignPtrContents
 - GHC.Prim.Int#
 - GHC.Prim.Int#
 - GHC.Prim.Int#
 - [Data.ByteString.Base.ByteString]
\end{core}
This is exactly what Duncan wanted, right? I declare victory :-)

However, things are not all roses. There are some functions that will
not be unboxed as we hope for with this approach, for instance the function
flushOld (see Duncan's code). To achieve the best possible optimization I
think one would have to perform strictness analysis and the worker-wrapper
transformation twice, once before doing local defunctionalization and then
again on the apply functions generated by the defunctionalization process.
This should give the code that Duncan wants I believe.

I think it should be relatively straightforward to implement local
defunctionalization in GHC but it should not be turned on by default as the
number of modules where it is beneficial is rather few.

The complete defunctionalized version of Duncan's module is attached.

I'm sure there are a lot of things that are somewhat unclear in this message.
Feel free to ask and I'll do my best to clarify.

Cheers,

Josef
{-# OPTIONS -fglasgow-exts -fbang-patterns -cpp #-}

module PutMonad (
-- * The Put type
  Put
, run -- :: Put () - L.ByteString

-- * Flushing the implicit parse state
, flush   -- :: Put ()

-- * Primitives
, write   -- :: Int - (Ptr Word8 - IO ()) - Put ()
, word8   -- :: Word8 - Put ()
  ) where

import Foreign
import qualified Data.ByteString.Base as B (
   ByteString(PS), LazyByteString(LPS),
   inlinePerformIO, mallocByteString, nullForeignPtr)
import qualified Data.ByteString.Lazy as L (ByteString)

-- Our internal buffer 

Re: Error compiling GHC/Num.lhs

2007-05-01 Thread Bas van Dijk

On 4/29/07, Ian Lynagh [EMAIL PROTECTED] wrote:


Hi Bas,

On Sun, Apr 29, 2007 at 11:54:35AM +, Bas van Dijk wrote:

 I'm trying to build GHC from darcs. Unfortunately compilation fails
 with the following error:

 ...
 cpphs: #error Please define LEFTMOST_BIT to be 2^(SIZEOF_HSWORD*8-1)
 in GHC/Num.lhs  at line 27 col 1
 make[1]: *** [doc.library.base] Error 1
 make[1]: Leaving directory `/home/bas/development/haskell/ghc/libraries'
 make: *** [stage1] Error 2
 ...

 The following is the part where the error occurs in
 libraries/base/GHC/Num.lhs :
 ...
 #include MachDeps.h
 #if SIZEOF_HSWORD == 4

This is a cpphs bug - IIRC it wasn't recursively expanding
SIZEOF_HSWORD. Either install cpphs from darcs (I don't think there is a
release with the fix yet) or uninstall it so that cpp is used instead.


Thanks
Ian


After uninstalling cpphs the error no longer occurs, thanks!

However the build now crashes when running Haddock on Cabal:
...
ifBuildable/ifBuildable Cabal setup/Setup haddock
Preprocessing library Cabal-1.1.7...
Running Haddock for Cabal-1.1.7...
Warning: cannot use package base-2.1:
  ghc-pkg failed
dist/build/tmp/Distribution/PreProcess.hs:Distribution/PreProcess.hs:
115:1: parse error in doc string: [TokSpecial '/',TokString
build,TokSpecial '']
make[1]: *** [doc.library.Cabal] Error 1
make[1]: Leaving directory `/home/bas/development/haskell/ghc/libraries'
make: *** [stage1] Error 2

The respected code from libraries/Cabal/Distribution/PreProcess.hs
(line 115 and onwards a bit):

data PreProcessor = PreProcessor {

 -- Is the output of the pre-processor platform independent? eg happy
output
 -- is portable haskell but c2hs's output is platform dependent.
 -- This matters since only platform independent generated code can
be
 -- inlcuded into a source tarball.
 platformIndependent :: Bool,

 -- TODO: deal with pre-processors that have implementaion dependent
output
 --   eg alex and happy have --ghc flags. However we can't really
inlcude
 --   ghc-specific code into supposedly portable source tarballs.

 runPreProcessor :: (FilePath, FilePath) -- Location of the source
file relative to a base dir
 - (FilePath, FilePath) -- Output file name,
relative to an output base dir
 - Int  -- verbosity
 - IO ()-- Should exit if the preprocessor fails
 }

Do I maybe need a newer Haddock for this? Currently I have version
0.8. Installing darcs version right now...

Thanks,

Bas van Dijk
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Wanted: warning option for usages of unary minus

2007-05-01 Thread Isaac Dupree
Okay, first steps:
1. A Trac ticket (#1318,
http://hackage.haskell.org/trac/ghc/ticket/1318) (is feature request a
good category, versus task?)
2. A test-case to make sure I don't break anything with existing '-'
syntax.  I'm guessing it should go in
testsuite/tests/ghc-regress/parser/should_run/, although maybe since it
checks Haskell-98 compatibility it should go in the testsuite/tests/h98
directory? (tested ghc and hugs, which both pass)

Isaac


(test-case attached in case anyone wants to look at or review it; I'll
send a darcs patch adding the testcase once I know where to put it)
-- !!! Haskell-98 prefix negate operator

-- Make sure the parsing is actually the correct
-- one by running this after it's compiled.

negatedExpression = - (3 + 4)

negatedTightlyBinding = -3^4

negatedNonSection = (- 3)

negatedNonSectionWithHighPrecedenceOp =
  let { f = (+); infix 9 `f` } in ( -3 `f` 4 )

negatedNonSectionWithLowPrecedenceOp =
  let { f = (+); infix 1 `f` } in ( -3 `f` 4 )

negatedRightHandSide =
-- This is actually not legal syntax:  3 * - 4
-- However, lower-precedence binary ops work.
-- (see H98 syntax for exp, or imagine it's because it
--  would parse differently as 3 * 0 - 4)
  let { f = (+); infix 1 `f` } in ( 3 `f` - 4 )


subtractionNotNegation = 3 -4

negativePattern =
case -3 of { (- 3) -
case -4 of { - 4 -
True } }
-- not legal H98 syntax:  case -4 of { _x @ -4 -
-- (parentheses needed)case -5 of { ~ -5 -

subtractionNotNegationPattern =
-- defines infix '-' (shadowing Prelude definition)
let { 3 -4 = True } in (3 - 4)

precedenceOfNegationCantBeChanged =
let { (-) = undefined; infix 9 - } in (- 3 * 4)

negationCantBeQualified =
(Prelude.-3) 4

main = do
  print negatedExpression
  print negatedTightlyBinding
  print negatedNonSection
  print negatedNonSectionWithHighPrecedenceOp
  print negatedNonSectionWithLowPrecedenceOp
  print negatedRightHandSide
  print subtractionNotNegation
  print negativePattern
  print subtractionNotNegationPattern
  print precedenceOfNegationCantBeChanged
  print negationCantBeQualified

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell] Translation of the Gentle Introduction to Haskell 98

2007-05-01 Thread Gorgonite
Hello,


I don't know if there are French-speaking people reading this
mailing-list, but we at haskell-fr have some great news today !

We didn't find any French translation of the Gentle Introduction to
Haskell (version 98), thus we decide to write it.
Today, I would like to announce that  we have completed a translation into
French, that it can be read by following the link :

http://gorgonite.developpez.com/livres/traductions/haskell/gentle-haskell/


It is currently available as a set of HTML pages.  We are
also putting into the official format with *.verb files.
Hopefully you will soon be able to download that version as well.


Please send your comments and suggestions to the French Haskell
mailing list [EMAIL PROTECTED]



Best regards,



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


[Haskell] Haskell fast (?) arrays

2007-05-01 Thread Federico Squartini

I was reading an old post where Hal Daume III was analyzing Haskell
performance for arrays.
He proposed a test program which initializes an array, reverse it a number
of times, and sums the contents.

So I wrote a c++ reference program, a naive haskell version using lists and
I also tweaked a little bit with the IOArray version, which should be the
fastest. Unfortunately there is a  huge performance gap. Haskell is slower
by a factor of ten, even when using imperative style.

C++
time ./arrayC
499
real0m0.059s
user0m0.044s
sys0m0.008s

HASKELL - IOUArray
time ./IOMutArrayUnboxed
499
real0m0.720s
user0m0.571s
sys0m0.019s

HASKELL - list
time ./list
499
real0m1.845s
user0m1.770s
sys0m0.064s


Can anyone suggest a faster version (using whatever data structure)? I like
Haskell very much but I still have to figure out if the slowness of some
code is due to my lack of knowledge or to some intrinsic limitation of the
language (or libraries).

By the way, sorry for the poor quality of the code, I am not a computer
scientist.


---

---
//compile with
//g++ -o arrayC arrayC.cc
#include stdio.h
#include  math.h



int main()
{
 int array[51];

 for (int i=0;i=50;i++)
   {
   array[i]=(19*i+23)%911;
   }
 int tmp=0;
 for (int cnt=0;cnt12;cnt++)
   {
 for (int x=0;x=25;x++)
   {
 tmp=array[50-x];
 array[50-x]=array[x];
 array[x]=tmp;
   }
   }
 int result=0;
 for (int i=0;i=50;i++)
   {
 result=result+(array[i]%911);
   }
 result=result % 911;
 printf(%d,result);
 return 0;
}

-

-
-- compile with
-- ghc --make -o list list.hs
module Main
   where

testArray = [ (19*i+23) `mod` 911 |i - [0..50]]

sumArrayMod =  foldl (\x y - (y+x) `mod` 911) 0

main = print $ sumArrayMod$
  reverse$ reverse$ reverse$ reverse$
  reverse$ reverse$ reverse$ reverse$
  reverse$ reverse$ reverse$ reverse$
  reverse$ reverse$ reverse$ reverse$
  testArray


-

-
-- compile with
-- ghc --make -o IOMutArrayUnboxed IOMutArrayUnboxed.hs
module Main
   where

import Monad
import Data.Array.IO
import Data.Array.MArray
import Data.Array.Unboxed

total, semiTotal ::Int
total= 50
semiTotal=25


testArray :: IO (IOUArray Int Int)
testArray = newListArray (0,total)  [(19*i+23) `mod` 911 |i - [0..total]]


reverseArray :: IOUArray Int Int - IO ()
reverseArray arr = mapM_  (\i - do oldi - readArray arr i
   oldj - readArray arr (total-i)
   writeArray arr i oldj
   writeArray arr (total-i) oldi)
  [0..semiTotal]

sumArrayMod :: IOUArray Int Int - IO Int
sumArrayMod arr = foldM (\s i - do x - readArray arr i
 return   $!(s+x)
`mod` 911) 0 [0..total]


main::IO()
main = testArray = \a -
  reverseArray a  reverseArray a  reverseArray a  reverseArray a



  reverseArray a  reverseArray a  reverseArray a  reverseArray a



  reverseArray a  reverseArray a  reverseArray a  reverseArray a



  reverseArray a  reverseArray a  reverseArray a  reverseArray a



  sumArrayMod a =  print

-

Federico
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Axel Simon
Frederico,

On Tue, 2007-05-01 at 13:59 +0200, Federico Squartini wrote:
 I was reading an old post where Hal Daume III was analyzing Haskell
 performance for arrays. 
 He proposed a test program which initializes an array, reverse it a
 number of times, and sums the contents.
 
 So I wrote a c++ reference program, a naive haskell version using
 lists and I also tweaked a little bit with the IOArray version, which
 should be the fastest. Unfortunately there is a  huge performance gap.
 Haskell is slower by a factor of ten, even when using imperative
 style. 

I think the version using lists is a bit unfair, since in C++ you don't
re-allocate the array on the heap and the Haskell version gives you a
very nice high-level abstraction of lists.

With respect to the imperative version, I would suggest

a) letting the program run for longer so you get more reliable timing.
b) use a similar optimisations that we've done for a demo of modifying
images in-situ for our Gtk2Hs library (in
http://darcs.haskell.org/gtk2hs/demo/fastdraw/FastDraw.hs ):

import Data.Array.Base ( unsafeWrite )

doFromTo 0 255 $ \y -
  doFromTo 0 255 $ \x -
-- Here, writeArray was replaced with unsafeWrite. The latter does
-- not check that the index is within bounds which has a tremendous
-- effect on performance.
--  writeArray  pbData (2+x*chan+y*row) blue  -- checked indexing
unsafeWrite pbData (2+x*chan+y*row) blue  -- unchecked indexing

Here, doFromTo is much faster and using unsafeWrite instead of
writeArray eliminates the array bound check, which is a big win again.
Then again, it is questionable if you really want to do that kind of
low-level programming in Haskell.

Axel.


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


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Stefan O'Rear
On Tue, May 01, 2007 at 01:59:01PM +0200, Federico Squartini wrote:
 I was reading an old post where Hal Daume III was analyzing Haskell
 performance for arrays.
 He proposed a test program which initializes an array, reverse it a number
 of times, and sums the contents.
 
 So I wrote a c++ reference program, a naive haskell version using lists and
 I also tweaked a little bit with the IOArray version, which should be the
 fastest. Unfortunately there is a  huge performance gap. Haskell is slower
 by a factor of ten, even when using imperative style.

I'd recommend using -O2 or -O.  GHC doesn't even try to generate fast
code if you don't use them. 

Stefan
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Federico Squartini

Of course I know that the list version is very unfair, but I wanted to see
what was the trade off between elegance and speed.
Regarding whether low level programming makes sense or not, I was just
curious to see what are the limits of Haskell. Moreover there is not much
literature on high performance Haskell programming (tricks like
unsafeWrite), at least organized in a systematic and concise way.

My original problem was writing a  fast library for simple matrix
computations (i.e. multiplication and inversion for small dense matrices).
I have not been able to make GSLHaskell work with Lapack so far. :(

Anyway here are the new versions and timings, I increased the number of
times the vector is reversed, I also compiled everything with -O2.

time ./arrayC
499
real0m0.244s
user0m0.236s
sys0m0.005s

time ./list
499
real0m11.036s
user0m10.770s
sys0m0.118s

time ./IOMutArrayUnboxed
499
real0m2.573s
user0m2.408s
sys0m0.042s

time ./IOMutUnbUnsafe
499
real0m2.264s
user0m2.183s
sys0m0.025s

--
--

//compile with g++ -O2 -o arrayC arrayC.cc
#include  stdio.h
#include math.h



int main()
{
 int array[51];

 for (int i=0;i=50;i++)
   {
   array[i]=(19*i+23)%911;
   }
 int tmp=0;
 for (int cnt=0;cnt120;cnt++)
   {
 for (int x=0;x=25;x++)
   {
 tmp=array[50-x];
 array[50-x]=array[x];
 array[x]=tmp;
   }
   }
 int result=0;
 for (int i=0;i=50;i++)
   {
 result=result+(array[i]%911);
   }
 result=result % 911;
 printf(%d,result);
 return 0;
}




-- compile with
-- ghc -O2 --make -o list list.hs

module Main
   where

import Data.List

testArray = [ (19*i+23) `mod` 911 |i - [0..50]]

sumArrayMod =  foldl (\x y - (y+x) `mod` 911) 0

main = print $ sumArrayMod$
  foldl (.) id  (replicate 120 reverse) $testArray

--

-- compile with
-- ghc -O2 --make -o IOMutArrayUnboxed IOMutArrayUnboxed.hs
module Main
   where

import Monad
import Data.Array.IO http://data.array.io/
import Data.Array.MArray
import Data.Array.Unboxed

total, semiTotal ::Int
total= 50 javascript:void(0)
semiTotal=25


testArray :: IO (IOUArray Int Int)
testArray = newListArray (0,total)  [(19*i+23) `mod` 911 |i - [0..total]]


reverseArray :: IOUArray Int Int - IO ()
reverseArray arr = mapM_  (\i - do oldi - readArray arr i
   oldj - readArray arr (total-i)
   writeArray arr i oldj
   writeArray arr (total-i) oldi)
  [0..semiTotal]

sumArrayMod :: IOUArray Int Int - IO Int
sumArrayMod arr = foldM (\s i - do x - readArray arr i
   return   $!(s+x) `mod` 911) 0 [0..total]


main::IO()
main = testArray = \a -
  sequence  (replicate 120 $reverseArray a)
  sumArrayMod a =  print




-- compile with
-- ghc -O2 --make -o IOMutUnbUnsafe IOMutUnbUnsafe.hs
module Main
   where

import Monad
import Data.Array.IO http://data.array.io/
import Data.Array.MArray
import Data.Array.Unboxed
import Data.Array.Base ( unsafeWrite, unsafeRead )

total, semiTotal ::Int
total= 50 javascript:void(0)
semiTotal=25


testArray :: IO (IOUArray Int Int)
testArray = newListArray (0,total)  [(19*i+23) `mod` 911 |i - [0..total]]


reverseArray :: IOUArray Int Int - IO ()
reverseArray arr = mapM_  (\i - do oldi - unsafeRead arr i
   oldj - unsafeRead arr (total-i)
   unsafeWrite arr i oldj
   unsafeWrite arr (total-i) oldi)
  [0..semiTotal]

sumArrayMod :: IOUArray Int Int - IO Int
sumArrayMod arr = foldM (\s i - do x - unsafeRead arr i
   return   $!(s+x) `mod` 911) 0 [0..total]



main::IO()
main = testArray = \a -
  doFromTo 1 120 (\_ - reverseArray a)  sumArrayMod a =  print



{-# INLINE doFromTo #-}
-- do the action for [from..to], ie it's inclusive.
doFromTo :: Int - Int - (Int - IO ()) - IO ()
doFromTo from to action =
 let loop n | n  to   = return ()
| otherwise = do action n
 loop (n+1)
  in loop from

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


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Donald Bruce Stewart
federico.squartini:
 
Of course I know that the list version is very unfair, but I
wanted to see what was the trade off between elegance and
speed.
Regarding whether low level programming makes sense or not,
I was just curious to see what are the limits of Haskell.
Moreover there is not much literature on high performance
Haskell programming (tricks like unsafeWrite), at least
organized in a systematic and concise way.
My original problem was writing a  fast library for simple
matrix computations (i.e. multiplication and inversion for
small dense matrices).  I have not been able to make
GSLHaskell work with Lapack so far. :(
Anyway here are the new versions and timings, I increased
the number of times the vector is reversed, I also compiled
everything with -O2.

Probably a good idea to use techniques from Data.ByteString (ie. use
strict Ptr loops, and Foreign arrays), or techniques from the shootout,
if you're chasing C speed. Good examples are:


http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievebitslang=ghcid=4
(mutable bit arrays)


http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievelang=ghcid=0
(mutable byte (foreign) arrays)


http://shootout.alioth.debian.org/gp4/benchmark.php?test=spectralnormlang=ghcid=4
(more mutable arrays)

When I really really care about speed, I use 

Foreign.Marshal.Array
Data.ByteString

and apply ! patterns liberally, checking the Core output for inner
loops. -O2 -optc-O2 -optc-march=pentium4 often helps.

1-4x C is around what you can best hope for. 10x says still room for
improvement in my experience.

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


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Federico Squartini

Sorry, I was very silly!

This is the correct version of the program using the doFromto loop.
And it runs fast! I hope there are no further mistakes.
Thanks Axel.

time ./IOMutUnbUnsafe
499
real0m0.708s
user0m0.573s
sys 0m0.008s



-
-- compile with
-- ghc --make -o IOMutUnbUnsafe IOMutUnbUnsafe.hs
module Main
   where

import Monad
import Data.Array.IO
import Data.Array.MArray
import Data.Array.Unboxed
import Data.Array.Base ( unsafeWrite, unsafeRead )

total, semiTotal ::Int
total= 50
semiTotal=25


testArray :: IO (IOUArray Int Int)
testArray = newListArray (0,total)  [(19*i+23) `mod` 911 |i - [0..total]]


reverseArray :: IOUArray Int Int - IO ()
reverseArray arr = doFromTo 0 semiTotal (\i - do oldi - unsafeRead arr i

oldj - unsafeRead arr (total-i)

unsafeWrite arr i oldj

unsafeWrite arr (total-i) oldi)

sumArrayMod :: IOUArray Int Int - IO Int
sumArrayMod arr = foldM (\s i - do x - unsafeRead arr i
return
$!(s+x) `mod` 911) 0 [0..total]


main::IO()
main = testArray = \a -
  doFromTo 1 120 (\_ - reverseArray a)  sumArrayMod a =  print



{-# INLINE doFromTo #-}
-- do the action for [from..to], ie it's inclusive.
doFromTo :: Int - Int - (Int - IO ()) - IO ()
doFromTo from to action =
 let loop n | n  to   = return ()
| otherwise = do action n
 loop (n+1)
  in loop from

---

Federico
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Federico Squartini

Thanks for the hints. It's a pity that (as far as I know) no one has
written a tutorial on those techniques, because I think it would be
appreciated. Some of them are quite involved and learning them just by
reading code is very time consuming.


Federico
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Rishiyur Nikhil

I think another interesting data point would be for a C++ version
that uses the 'vector' data type from STL (Standard Template Library)
and using the vector indexing ops that do bounds-checking.

Regards,

Nikhil
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Taral

On 5/1/07, Federico Squartini [EMAIL PROTECTED] wrote:

Thanks for the hints. It's a pity that (as far as I know) no one has
written a tutorial on those techniques, because I think it would be
appreciated. Some of them are quite involved and learning them just by
reading code is very time consuming.


I personally recommend to people that if sections of your code are
really performance-critical, you should consider writing them in a
lower-level lanaguage like C and using FFI for access.

P.S. I wonder if jhc could improve the output code?

--
Taral [EMAIL PROTECTED]
You can't prove anything.
   -- Gödel's Incompetence Theorem
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] refactoring, catamorphism, termination of programs

2007-05-01 Thread Johannes Waldmann

Dear all,

I'm looking for a tool that implements the source code transformation
replace recursion by catamorphism (fold etc.).

My application is that if the transformation succeeds,
it implies that the program terminates. (roughly)

I don't want to make a big research project out of this,
rather I think of quickly putting together a prototype
that proves the concept.

I figure it could be distilled from some existing refactoring suite,
or be manufactured from existing building blocks.

E.g. Language.Haskell.* from the ghc libs,
and perhaps Typing Haskell in Haskell?
http://citeseer.ist.psu.edu/424440.html

Any hints appreciated.

Of course, if you already have some termination prover
for Haskell programs, using any method whatsoever,
then you're invited to take part
in the FP category of the upcoming Termination Competition,
see http://www.lri.fr/~marche/termination-competition/2007/

(Also, I'd welcome your comments on the proposed form
and semantics of the FP category.)
For discussion, please do not use this list but
http://groups.google.de/group/fp-termination


Best regards, Johannes Waldmann.

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


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Bas van Dijk

On 5/1/07, Federico Squartini [EMAIL PROTECTED] wrote:

Moreover there is not much literature on high performance Haskell programming
(tricks like unsafeWrite), at least organized in a systematic and concise way.


Look at: http://haskell.org/haskellwiki/Performance

regards,

Bas van Dijk
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Stephan Herhut

While scanning my Inbox I read 'fast' and 'array' in the context of
functional programming. Well, of course SaC instantly came to my mind (what
a surprise ;) ). So I did some measurements myself. I used your programs,
except that I increased the array size by a factor of 10. For the C++
version I had to move the array to the heap and fix the order of function
applications within the fold. Here are the timings:

C++
520
real0m0.204s
user0m0.182s
sys 0m0.023s

Haskell IOArray (the extended version with unsafe accesses that was posted
shortly after yours)
520

real0m5.542s
user0m5.453s
sys 0m0.068s

Haskell Lists (just to be complete)
520

real0m27.596s
user0m26.650s
sys 0m0.870s

and finally SaC
Dimension:  0
Shape:  
520

real0m0.057s
user0m0.048s
sys 0m0.000s

The corresponding SaC program follows. I have compiled it with sac2c -O3. I
used the current compiler from the website http://www.sac-home.org.

use Structures : all;
use StdIO : all;

inline
int sumMod( int a, int b)
{
 return( (a + b) % 911);
}

inline
int sumArrayMod( int[*] A)
{
 res = with {
 ( shape(A) * 0 = iv  shape(A)) : A[iv];
   } : fold( sumMod, 0);

 return( res);
}

int main() {
 testArray = (19*iota(501)+23) % 911;

 print( sumArrayMod(
   reverse( reverse( reverse( reverse(
   reverse( reverse( reverse( reverse(
   reverse( reverse( reverse( reverse(
   reverse( reverse( reverse( reverse(
 testArray));

 return( 0);
}

On 5/1/07, Federico Squartini [EMAIL PROTECTED] wrote:


I was reading an old post where Hal Daume III was analyzing Haskell
performance for arrays.
He proposed a test program which initializes an array, reverse it a number
of times, and sums the contents.

So I wrote a c++ reference program, a naive haskell version using lists
and I also tweaked a little bit with the IOArray version, which should be
the fastest. Unfortunately there is a  huge performance gap. Haskell is
slower by a factor of ten, even when using imperative style.

C++
time ./arrayC
499
real0m0.059s
user0m0.044s
sys0m0.008s

HASKELL - IOUArray
time ./IOMutArrayUnboxed
499
real0m0.720s
user0m0.571s
sys0m0.019s

HASKELL - list
time ./list
499
real0m1.845s
user0m1.770s
sys0m0.064s


Can anyone suggest a faster version (using whatever data structure)? I
like Haskell very much but I still have to figure out if the slowness of
some code is due to my lack of knowledge or to some intrinsic limitation of
the language (or libraries).

By the way, sorry for the poor quality of the code, I am not a computer
scientist.


---


---
//compile with
//g++ -o arrayC arrayC.cc
#include stdio.h
#include  math.h



int main()
{
  int array[51];

  for (int i=0;i=50;i++)
{
array[i]=(19*i+23)%911;
}
  int tmp=0;
  for (int cnt=0;cnt12;cnt++)
{
  for (int x=0;x=25;x++)
{
  tmp=array[50-x];
  array[50-x]=array[x];
  array[x]=tmp;
}
}
  int result=0;
  for (int i=0;i=50;i++)
{
  result=result+(array[i]%911);
}
  result=result % 911;
  printf(%d,result);
  return 0;
}

-


-
-- compile with
-- ghc --make -o list list.hs
module Main
where

testArray = [ (19*i+23) `mod` 911 |i - [0..50]]

sumArrayMod =  foldl (\x y - (y+x) `mod` 911) 0

main = print $ sumArrayMod$
   reverse$ reverse$ reverse$ reverse$
   reverse$ reverse$ reverse$ reverse$
   reverse$ reverse$ reverse$ reverse$
   reverse$ reverse$ reverse$ reverse$
   testArray


-


-
-- compile with
-- ghc --make -o IOMutArrayUnboxed IOMutArrayUnboxed.hs
module Main
where

import Monad
import Data.Array.IO
import Data.Array.MArray
import Data.Array.Unboxed

total, semiTotal ::Int
total= 50
semiTotal=25


testArray :: IO (IOUArray Int Int)
testArray = newListArray (0,total)  [(19*i+23) `mod` 911 |i - [0..total]]


reverseArray :: IOUArray Int Int - IO ()
reverseArray arr = mapM_  (\i - do oldi - readArray arr i
oldj - readArray arr (total-i)
writeArray arr i oldj
writeArray arr (total-i) oldi)
   [0..semiTotal]

sumArrayMod :: IOUArray Int Int - IO Int
sumArrayMod arr = foldM (\s i - do x - readArray arr i
 

[Haskell] Re: refactoring, catamorphism, termination of programs

2007-05-01 Thread Stefan Monnier
 I'm looking for a tool that implements the source code transformation
 replace recursion by catamorphism (fold etc.).

 My application is that if the transformation succeeds,
 it implies that the program terminates. (roughly)

 I don't want to make a big research project out of this,
 rather I think of quickly putting together a prototype
 that proves the concept.

Have you considered another approach?

E.g. the Coq papers define its elimination constructs either as
a catamorphism, or as a combination of casefix, where the recursive calls
are appropriately restricted to pass subterms as arguments.

See for example Eduardo Gimenez's Codifying guarded definition with
recursive schemes.  This paper also shows how to turn such a casefix into
a call to a catamorphism.


Stefan

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


[Haskell] ANNOUNCE: rsa-haskell 2.0.1

2007-05-01 Thread David Sankel

RSA-Haskell is a collection of command-line cryptography tools and a
cryptography library written in Haskell. It is intended to be useful
to anyone who wants to secure files or communications or who wants to
incorporate cryptography in their Haskell application.

Download and documentation are available at
http://www.netsuperbrain.com/rsa-haskell.html

In this 2.0.1 release I've added a bunch of documentation and
incorporated an archive with windows binaries for the command line
tools.

Please let me know if you have any questions or comments.

Enjoy!

David

--
David Sankel
Sankel Software
www.sankelsoftware.com
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] refactoring, catamorphism, termination of programs

2007-05-01 Thread José Pedro Correia

Hi
Maybe this link is of interest to you:
http://wiki.di.uminho.pt/twiki/bin/view/Research/PURe/WebHome.
A tool called DrHylo, developed in the context of this project is available,
altough I don't know how suitable it could be for you:
http://wiki.di.uminho.pt/twiki/bin/view/Personal/Alcino/DrHylo.

Regards
José Pedro

On 5/1/07, Johannes Waldmann [EMAIL PROTECTED] wrote:


Dear all,

I'm looking for a tool that implements the source code transformation
replace recursion by catamorphism (fold etc.).

My application is that if the transformation succeeds,
it implies that the program terminates. (roughly)

I don't want to make a big research project out of this,
rather I think of quickly putting together a prototype
that proves the concept.

I figure it could be distilled from some existing refactoring suite,
or be manufactured from existing building blocks.

E.g. Language.Haskell.* from the ghc libs,
and perhaps Typing Haskell in Haskell?
http://citeseer.ist.psu.edu/424440.html

Any hints appreciated.

Of course, if you already have some termination prover
for Haskell programs, using any method whatsoever,
then you're invited to take part
in the FP category of the upcoming Termination Competition,
see http://www.lri.fr/~marche/termination-competition/2007/

(Also, I'd welcome your comments on the proposed form
and semantics of the FP category.)
For discussion, please do not use this list but
http://groups.google.de/group/fp-termination


Best regards, Johannes Waldmann.

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

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


[Haskell] ANNOUNCE: Atom 2007.05

2007-05-01 Thread Tom Hawkins

Atom, a high-level hardware description language embedded in Haskell,
compiles conditional term rewriting systems into conventional HDL.

New in this release:

 - VHDL code generation (synthesis only, simulation directives not supported).

 - Improved rule mutual exclusion analysis.  Now, mutual exclusion
   can be verified on many rule conditions without having to use MiniSat.

 - Automatic reset and clock generation for IO-less systems (Verilog only).
   Eliminates the need for separate Verilog testbenches when both
   the design and stimulus are described in Atom.

 - And few additions to the library.

Enjoy!

 http://www.funhdl.org/

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


Re: [Haskell] Haskell fast (?) arrays

2007-05-01 Thread Donald Bruce Stewart
federico.squartini:
 Sorry, I was very silly!
 
 This is the correct version of the program using the doFromto loop.
 And it runs fast! I hope there are no further mistakes.
 Thanks Axel.
 
 time ./IOMutUnbUnsafe
 499
 real  0m0.708s
 user  0m0.573s
 sys   0m0.008s

Here's an improved version, using Foreign.Marshal.Array. I spent about 2
minutes inspecting the core, as well.

Before, with your IOUArray version:

$ time ./T
499
./T  1.46s user 0.02s system 97% cpu 1.515 total

with the new version:

$ time ./S
499
./S  1.15s user 0.01s system 99% cpu 1.168 total

Here's the source, its more idiomatic high-perf Haskell, I'd argue.

Cheers,
  Don




{-# OPTIONS -O2 -optc-O -optc-march=pentium4 -fbang-patterns #-}

import Control.Monad
import Foreign.Marshal.Array
import Foreign

total :: Int
total = 51

type Arr = Ptr Int

testArray :: IO Arr
testArray = do
u - mallocArray total :: IO Arr
forM_ [0 .. total] $ \i - pokeElemOff u i ((19*i+23) `mod` 911)
return u

reverseArray :: Arr - Int - Int - IO ()
reverseArray !p !i !j
| i  j = do
x - peekElemOff p i
y - peekElemOff p j
pokeElemOff p i y
pokeElemOff p j x
reverseArray p (i+1) (j-1)
| otherwise = return ()

sumArrayMod :: Arr - Int - Int - IO Int
sumArrayMod !p !s !i
| i  total = do
x - peekElemOff p i
sumArrayMod p ((s + x) `rem` 911) (i+1)
| otherwise = return s

main :: IO ()
main = do
a - testArray
replicateM_ 120 (reverseArray a 0 (total-1))
print = sumArrayMod a 0 0

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


Re: Polymorphic strict fields

2007-05-01 Thread Duncan Coutts
On Mon, 2007-04-30 at 19:47 -0700, Iavor Diatchki wrote:

 All of this leads me to think that perhaps we should not allow
 strictness annotations on polymorphic fields.  Would people find this
 too restrictive?

Yes.

Our current implementation of stream fusion relies on this:

data Stream a = forall s. Unlifted s =
  Stream !(s - Step a s)  -- ^ a stepper function
 !s-- ^ an initial state

We use strictness on polymorphic (class constrained) fields to simulate
unlifted types. We pretend that the stream state types are all unlifted
and have various strict/unlifted type constructors:

data (Unlifted a, Unlifted b) = a :!: b = !a :!: !b
instance (Unlifted a, Unlifted b) = Unlifted (a :!: b) where ...


Duncan

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


[Haskell-cafe] Cabal, lib and exe in one

2007-05-01 Thread Magnus Therning
I'm trying to create a single cabal file containing specs for both a
library and an executable using that library.  I'm not having much luck
though :(

This is what I have so far:

  name: foo
  version: 0.1
  exposed-modules: Foo.Bar
  other-modules: Foo.Qux Foo.C2HS
  hs-source-dirs: src
  include-dirs: csrc
  c-sources: csrc/qux.c
  extensions: ForeignFunctionInterface
  build-depends: base, haskell98
  
  executable: foo
  hs-source-dirs: test-src
  main-is: foo.hs
  other-modules: Foo.Bar

When built this is the message I get:
  test-src/foo.hs:5:7:
  Could not find module `Foo.Bar':
Use -v to see a list of the files searched for.

How do I specify that Foo.Bar is found where cabal puts it
(./dist/build/)?

/M

-- 
Magnus Therning (OpenPGP: 0xAB4DFBA4)
[EMAIL PROTECTED] Jabber: [EMAIL PROTECTED]
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Finagle's Fifth Law:
Always draw your curves, then plot your readings.


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


RE: [Haskell-cafe] FIT for Haskell

2007-05-01 Thread Bayley, Alistair
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Philipp Volgger
 
 Who wrote FIT for Haskell on http://darcs.haskell.org/FIT/? 
 Does anybody know if the version is stable?

Hello Philipp,

That would be me. It's not finished or stable, and I don't think it'll
work with GHC-6.6 on Windows because it uses hs-plugins. I figured I'd
better save the code somewhere, because I lost some work when my laptop
died last year.

It's not finished in the sense that I haven't implemented all of the
test suite; I got as far as the Music Example in the standard tests
(http://fit.c2.com/wiki.cgi?MusicExample) but I have not implemented
RowFixture, which the Music Example requires. Also, the
Algol-derivative-language implementations of FIT (Java, C#, etc) use
static class variables (i.e. global mutable state) in the Music Example,
so there's some redesign work to get it to run in Haskell.

I'd be happy to explain how it works if you're interested in
contributing.

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


[Haskell-cafe] Re: 'Proper' use of the State monad

2007-05-01 Thread DavidA
 1) Using State GameState r and then call execState for each game event
 (i.e. user input) so I can do IO
 2) Using StateT GameState IO () and have the entire game live in one
 big execStateT call. (I note XMonad does something similar.)

I'm also interested in the answer to this question. One concern I would have 
about option 2 is that it looks like it breaks encapsulation, to use a phrase 
from OOP.

What I mean is, it seems like good design would mean that you could write and 
test the game logic totally independently of any IO. Game functions such 
as makeMove ought to have type signatures that don't involve any IO. Can this 
be achieved in option 2?


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


[Haskell-cafe] what exactly does deriving (Functor, Monad, MonadIO) do?

2007-05-01 Thread Thomas Hartman

I was trying to follow the reasoning in Don's article on using haskell
for shell scripting

 http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10

In the source listing at the end we is

 newtype Shell a = Shell { runShell :: ErrorT String IO a }
   deriving (Functor, Monad, MonadIO)

and I don't understand it what deriving is doing here, nor have I
been able to find documentation on it.

 http://en.wikibooks.org/wiki/Haskell/Class_declarations

claims:

You can only use deriving with a limited set of built-in classes. They are:

Eq  Ord Enum Bounded  Show  Read 

But, here we are deriving classes not in that list. So, is this a
recently added feature? Or something that came in from

 {-# OPTIONS -fglasgow-exts #-} ?

I would just like to understand this, and I can't figure out how to begin.

Thanks for any help!

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


Re: [Haskell-cafe] what exactly does deriving (Functor, Monad, MonadIO) do?

2007-05-01 Thread Donald Bruce Stewart
tphyahoo:
 I was trying to follow the reasoning in Don's article on using haskell
 for shell scripting
 
  http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10
 
 In the source listing at the end we is
 
  newtype Shell a = Shell { runShell :: ErrorT String IO a }
deriving (Functor, Monad, MonadIO)
 
 and I don't understand it what deriving is doing here, nor have I
 been able to find documentation on it.

That's 'cunning newtype deriving, my new favourite ghc language
extension.


http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#newtype-deriving

We also use it in xmonad,

newtype X a = X (ReaderT XConf (StateT XState IO) a)
deriving (Functor, Monad, MonadIO, MonadState XState, MonadReader XConf)

:-)

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


[Haskell-cafe] Re: Poor first impression

2007-05-01 Thread Simon Marlow

brad clawsie wrote:

On Mon, Apr 30, 2007 at 09:53:06PM +0100, Andrew Coppin wrote:

 brad clawsie wrote:

installing a modern linux on this box is a thirty minute exercise.

 Ah - a volunteer! :-)


absolutely! for the low cost of one round-trip business-class seat from
san jose to wherever this box is, and i will happily insert a recent 
ubuntu cd and click the install icon.


Well, no way is it a 30 minute job to upgrade the OS on a production multi-user 
Linux system.  Surely I don't need to go into details here.


A better solution would be to use someone else's box via BuildBot.  I think 
someone offered to donate a couple of FC boxes for the builds recently.


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


Re: [Haskell-cafe] what exactly does deriving (Functor, Monad, MonadIO) do?

2007-05-01 Thread Thomas Hartman

Thanks Dons.

There's also a short and sweet explanation here.

http://hackage.haskell.org/trac/haskell-prime/wiki/NewtypeDeriving

I am going to try and wrap my head around this, as I am very
interested in solutions for haskell / shell interaction.

Are there are any good examples of code written without this
extension, alongside code condensed by using this extension. That
would be helpful for understanding what's going on.

Thomas.



2007/5/1, Donald Bruce Stewart [EMAIL PROTECTED]:

tphyahoo:
 I was trying to follow the reasoning in Don's article on using haskell
 for shell scripting

  http://cgi.cse.unsw.edu.au/~dons/blog/2007/03/10

 In the source listing at the end we is

  newtype Shell a = Shell { runShell :: ErrorT String IO a }
deriving (Functor, Monad, MonadIO)

 and I don't understand it what deriving is doing here, nor have I
 been able to find documentation on it.

That's 'cunning newtype deriving, my new favourite ghc language
extension.


http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#newtype-deriving

We also use it in xmonad,

newtype X a = X (ReaderT XConf (StateT XState IO) a)
deriving (Functor, Monad, MonadIO, MonadState XState, MonadReader XConf)

:-)

-- Don


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


Re: [Haskell-cafe] Bloom Filter

2007-05-01 Thread Josef Svenningsson

Hi,

Just a small comment on one of the comments.

On 5/1/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Also, rather than this:

add :: Bloom a - a - Bloom a

a better argument order is this:

insert :: a - Bloom a - Bloom a

That way, you can use it with foldr.


Hmmm. If you want to create a Bloom using a fold wouldn't it make more
sense to use foldl'? I think the argument order is fine.

Cheers,

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


Re: [Haskell-cafe] Cabal, lib and exe in one

2007-05-01 Thread Duncan Coutts
On Tue, 2007-05-01 at 09:34 +0100, Magnus Therning wrote:
 I'm trying to create a single cabal file containing specs for both a
 library and an executable using that library.  I'm not having much luck
 though :(
 
 This is what I have so far:
 
   name: foo
   version: 0.1
   exposed-modules: Foo.Bar
   other-modules: Foo.Qux Foo.C2HS
   hs-source-dirs: src
   include-dirs: csrc
   c-sources: csrc/qux.c
   extensions: ForeignFunctionInterface
   build-depends: base, haskell98
   
   executable: foo
   hs-source-dirs: test-src
   main-is: foo.hs
   other-modules: Foo.Bar
 
 When built this is the message I get:
   test-src/foo.hs:5:7:
   Could not find module `Foo.Bar':
 Use -v to see a list of the files searched for.
 
 How do I specify that Foo.Bar is found where cabal puts it
 (./dist/build/)?

But surely Foo.Bar is in src, it is afterall exactly the same module as
the one you're using in the library, no?

So if foo.hs is in test-src and Foo/Bar.hs is in src then I think you
just need:

hs-source-dirs: test-src, src

You cannot specify that things are found in dist/build since that dir
can placed anywhere by the user. But I don't see that you'd want to, I
can't see how it makes any sense.

Duncan

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


Re: [Haskell-cafe] Re: 'Proper' use of the State monad

2007-05-01 Thread Sebastian Sylvan

On 5/1/07, DavidA [EMAIL PROTECTED] wrote:


 1) Using State GameState r and then call execState for each game event
 (i.e. user input) so I can do IO
 2) Using StateT GameState IO () and have the entire game live in one
 big execStateT call. (I note XMonad does something similar.)

I'm also interested in the answer to this question. One concern I would
have
about option 2 is that it looks like it breaks encapsulation, to use a
phrase
from OOP.

What I mean is, it seems like good design would mean that you could write
and
test the game logic totally independently of any IO. Game functions such
as makeMove ought to have type signatures that don't involve any IO. Can
this
be achieved in option 2?



You could, of course, do both.

I do think it's a good idea to write your own game monad which
encapsulates all of the unsafe functions that you might want to do in an
application specific approprate way, rather than just having your unsafe
skin be the IO monad. So for example, if you want to spawn an actor in the
game world and attach an AI thread to govern its behaviour you'd need a
function which interanlly uses forkIO, sets up a bunch of TVars for
messaging etc., but from the Game monad's pespective that can be
encapsulated. There *are* things which are just inherently imperative in
nature, and are easier to do like that (threads with message passing, for
example, is not necessarily bad, sometimes they are the Right Abstraction --
actor AI is probably a good example), but you can make it a lot nicer and
less unsafe by writing your own unsafe skin which supplies slightly safer
encapsulations tailored for your specific application.

But of course, you could have another monad which ONLY deals with pure
changes to the game state that you then evaluate from the underlying monad.
So the GameEngine monad is the unsafe skin, and then you have the Game
monad which just does a pure computation on the game state. Then you'd have
a function like:

game :: Game a - GameEngine a
game g = do
 state - get
 gstate - gameState state
 let ( res, gstate' ) = runState g
 put ( state{ gameState = gstate' } )
 return res

Which simply runs a game action on the game part of the GameEngine state.

--
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] what exactly does deriving (Functor, Monad, MonadIO) do?

2007-05-01 Thread Brandon S. Allbery KF8NH


On May 1, 2007, at 6:05 , Thomas Hartman wrote:


Are there are any good examples of code written without this
extension, alongside code condensed by using this extension. That
would be helpful for understanding what's going on.


I think all this does is save you from having to write a bunch of  
wrappers that unwrap the contained value, do something to it, and  
rewrap the result.


--
brandon s. allbery  [solaris,freebsd,perl,pugs,haskell]   
[EMAIL PROTECTED]
system administrator  [openafs,heimdal,too many hats]   
[EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon university   
KF8NH



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


Re: [Haskell-cafe] what exactly does deriving (Functor, Monad, MonadIO) do?

2007-05-01 Thread David House

On 01/05/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote:

I think all this does is save you from having to write a bunch of
wrappers that unwrap the contained value, do something to it, and
rewrap the result.


Exactly. Basically what newtype deriving does is if you have a
declaration like the following:

 newtype T = TConstructor M

And M instantiates some class (like Monad, Functor etc), you can
derive that class for T. For example, here's how the Functor instance
would look for the following newtype:

 newtype MyMaybe a = MM (Maybe a) deriving (Functor)

 -- The instance looks like this:
 instance Functor MyMaybe where
   fmap f (MM a) = MM (fmap f a)

The instance just unwraps and rewraps the newtype constructor.

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Displaying infered type signature of 'offside' functions

2007-05-01 Thread Simon Peyton-Jones
| I like the strong static type system of Haskell for various
| reasons. One reason is, that it makes easier to understand new
| code. I.e. when I read code I type ':t foo' in ghci/hugs from
| time to time, to check my own idea of the type signature, if it
| is not included in the source code.

The principal difficulties here are to do with what do we want rather the 
implementation challenges.

1.  Should the compiler print the type of every declaration? Should GHCi allow 
you to ask the type of a local decl?

2.  How should the variables be identified?  There may be many local bindings 
for 'f', so you can't say just :t f.  Ditto if dumping all local bindings.

3.  Do you want all locally-bound variables (including those bound by lambda or 
case), or just letrec/where bound ones?   I think 'all', myself, but there are 
a lot of them.

4.  (This is the trickiest one.)  The type of a function may mention type 
variables bound further out.  Consider
f :: [a] - Int
f xs = let v = head xs in ...

The type of 'v' is simply 'a'.  Not 'forall a. a', but rather 'if xs:[a] then 
*that* a!'  In general there may also be existential type variables bound by an 
enclosing pattern match too.

So it's not easy to see how to report v's type.  In general there is no type 
signature for f, which only makes matters worse, since there is no name to use 
for the in-scope type variable.


These are all user-interface issues.  If some people would like to thrash out a 
design, and put it on the Wiki, I think there is a good chance that someone 
(possibly even me) would implement it.

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


[Haskell-cafe] Re: Type-level programming problem

2007-05-01 Thread Thomas Schilling


On 1 maj 2007, at 06.12, [EMAIL PROTECTED] wrote:


We see it is a value polymorphic over four type variables: ns, a, b,
and c. The type variable 'a' is also the type of the value, so we have
a way to instantiate it. There is no direct way to instantiate the
remaining three. If there were a functional dependency a - ns, a-b,
a-c, we could have instantiated the remaining variables. But there
are no such dependencies. So, there is really no way we can
ever instantiate the type variables ns, b and c -- and so the  
typechecker

will complain.

So, we need either a functional dependency a - ns in the definition
of Foo, or defaultA should have a signature defaultA :: ns - a
(and ditto for other defaults).


In fact I had this signature for a while, but then I had already  
changed the definition of Foo to a different signature.  Good to know  
that I wasn't too far off..



As I understand, the function
'defaultA' can be present in different components, identified by
ns. When we write 'defaultA' however, how can we say that we mean
defaultA of component X rather than of component Y? There isn't any
way to name the desired component...

Incidentally, if we represent components by records
data XRec = XRec { defaultA :: XA }
then the type of defaultA is Xref - XA. It is the function from the
type of the `namespace'. This seems to suggest the
signature of defaultA should be ns - a ...

BTW, there are other ways to add the name of the namespace to the
signature of defaultA. For example:
newtype TaggedT ns a = TaggedT a
class Foo ns a b c | ...
 defaultA :: TaggedT ns a
or
class Foo ns a b c | ...
 defaultA :: ns a

etc.


Thank you for your quick and helpful response.  I'll look into what  
works best for my purposes.


Thanks,

/ Thomas

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


[Haskell-cafe] Hugs/nhc getting progressively slower

2007-05-01 Thread Neil Mitchell

Hi,

I like to develop on Hugs, because its a nice platform to work with,
and provides WinHugs, auto-reloading, sub-second compilation etc.
Unfortunately some of the newer libraries (ByteString/Binary in
particular) have been optimised to within an inch of their lives on
GHC, at the cost of being really really slow on Hugs.

Taking the example of Yhc Core files, which are stored in binary.
Using a very basic hPutChar sequence is miles faster (10x at least)
than all the fancy ByteString/Binary trickery.

Taking the example of nobench, Malcolm told me he reimplemented
ByteString in terms of [Char] and gained a massive performance
increase (6000x springs to mind, but that seems way too high to be
true) using nhc.

Could we have a collective thought, and decide whether we wish to
either kill off all compilers that don't start with a G, or could
people at least do minimal benchmarking on Hugs? I'm not quite sure
what the solution is, but it probably needs some discussion.

Thanks

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


[Haskell-cafe] Is Hs-Plugins dead?

2007-05-01 Thread Philipp Volgger
Is Hs-Plugins still under develeopment; is there still somebody who is 
updating it?



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


[Haskell-cafe] Bloom Filter

2007-05-01 Thread Dom
 
 Reminds me of this code from Data.Binary:
 
 unroll :: Integer - [Word8]
 unroll = unfoldr step
   where
 step 0 = Nothing
 step i = Just (fromIntegral i, i `shiftR` 8)
 
 roll :: [Word8] - Integer
 roll   = foldr unstep 0
   where
 unstep b a = a `shiftL` 8 .|. fromIntegral b
 
 Which is a bit stream-fusion inspired, I must admit.
 

But better than what is in Codec.Utils:

 toBase x =
map fromIntegral .
reverse .
map (flip mod x) .
takeWhile (/=0) .
iterate (flip div x)
 
 -- | Take a number a convert it to base n as a list of octets.
 
 toOctets :: (Integral a, Integral b) = a - b - [Octet]
 toOctets n x = (toBase n . fromIntegral) x

 powersOf n = 1 : (map (*n) (powersOf n))

 -- | Take a list of octets (a number expressed in base n) and convert it
 --   to a number.
 
 fromOctets :: (Integral a, Integral b) = a - [Octet] - b
 fromOctets n x =
fromIntegral $
sum $
zipWith (*) (powersOf n) (reverse (map fromIntegral x))

It seems a shame that everyone has to roll their own.

Dominic.

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


Re: [Haskell-cafe] Hugs/nhc getting progressively slower

2007-05-01 Thread Duncan Coutts
On Tue, 2007-05-01 at 20:37 +0100, Neil Mitchell wrote:
 Hi,
 
 I like to develop on Hugs, because its a nice platform to work with,
 and provides WinHugs, auto-reloading, sub-second compilation etc.
 Unfortunately some of the newer libraries (ByteString/Binary in
 particular) have been optimised to within an inch of their lives on
 GHC, at the cost of being really really slow on Hugs.
 
 Taking the example of Yhc Core files, which are stored in binary.
 Using a very basic hPutChar sequence is miles faster (10x at least)
 than all the fancy ByteString/Binary trickery.
 
 Taking the example of nobench, Malcolm told me he reimplemented
 ByteString in terms of [Char] and gained a massive performance
 increase (6000x springs to mind, but that seems way too high to be
 true) using nhc.

That does not surprise me.

 Could we have a collective thought, and decide whether we wish to
 either kill off all compilers that don't start with a G, or could
 people at least do minimal benchmarking on Hugs? I'm not quite sure
 what the solution is, but it probably needs some discussion.

I don't think doing minimal benchmarking on hugs will help at all unless
we are prepared to act on it and I'm pretty sure anything we do to
improve hugs performance will be detrimental to the GHC performance.

We're optimising for totally different sets of primitives. With GHC
we're optimising for machine code and thinking about branch prediction
and cache misses. We're also writing high level combinators that are
quite inefficient to execute directly but we rely on inlining and
rewrite rules to combine then expand them to efficient low level code.

With hugs/yhc/nhc I assume the optimisation technique is simply to
minimise the number of primitive reduction steps. This is really totally
different. I don't see any obvious way of reconciling the two in a
single implementation of an interface. Having totally different
implementations of an interface for different Haskell systems is an
option though it has obvious disadvantages.

So I don't know what to do. We're not stopping out quest for high
performance idiomatic code because it doesn't play nicely with
interpreters.

Duncan

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


Re: [Haskell-cafe] Cabal, lib and exe in one

2007-05-01 Thread Magnus Therning
On Tue, May 01, 2007 at 12:02:18 +0100, Duncan Coutts wrote:
On Tue, 2007-05-01 at 09:34 +0100, Magnus Therning wrote:
 I'm trying to create a single cabal file containing specs for both a
 library and an executable using that library.  I'm not having much luck
 though :(
 
 This is what I have so far:
 
   name: foo
   version: 0.1
   exposed-modules: Foo.Bar
   other-modules: Foo.Qux Foo.C2HS
   hs-source-dirs: src
   include-dirs: csrc
   c-sources: csrc/qux.c
   extensions: ForeignFunctionInterface
   build-depends: base, haskell98
   
   executable: foo
   hs-source-dirs: test-src
   main-is: foo.hs
   other-modules: Foo.Bar
 
 When built this is the message I get:
   test-src/foo.hs:5:7:
   Could not find module `Foo.Bar':
 Use -v to see a list of the files searched for.
 
 How do I specify that Foo.Bar is found where cabal puts it
 (./dist/build/)?

But surely Foo.Bar is in src, it is afterall exactly the same module as
the one you're using in the library, no?

Yes.

So if foo.hs is in test-src and Foo/Bar.hs is in src then I think you
just need:

hs-source-dirs: test-src, src

No, that's not enough, I also have to add the following lines to make
the executable compile and link:

  extensions: ForeignFunctionInterface
  c-sources: csrc/ptrace.c

That is, I end up compiling the library a second time!  Can't I get the
executable to link against the library that was just created?

You cannot specify that things are found in dist/build since that dir
can placed anywhere by the user. But I don't see that you'd want to, I
can't see how it makes any sense.

I was just expecting to not have to repeat myself in the cabal file.
Not such a strange thing to expect from a build system, I think :-)

Also, I don't really see what you mean by that dir can be placed
anywhere by the user.  That dir is created as part of the build
process and it's location is, AFAICS, always going to be ./dist/build.
Finding the library after installation is another matter, but that
problem should be taken care of during the `./Setup.hs configure` stage.

/M

-- 
Magnus Therning (OpenPGP: 0xAB4DFBA4)
[EMAIL PROTECTED] Jabber: [EMAIL PROTECTED]
http://therning.org/magnus


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


Re: [Haskell-cafe] Re: 'Proper' use of the State monad

2007-05-01 Thread Yitzchak Gale

DavidA wrote:

What I mean is, it seems like good design would mean that you could write and
test the game logic totally independently of any IO. Game functions such
as makeMove ought to have type signatures that don't involve any IO. Can this
be achieved in option 2?


Here is one way:

For functions that do not need IO, use types that look like:

MonadState GameState m = ... - m a

For functions that only do IO without refering to the
game state, use:

MonadIO m = ... - m a

For functions that do both, use:

(MonadIO m, MonadState GameState m) = ... - m a

Testing of the pure game functions can use
State GameState, testing of pure IO functions can
use IO, and production can use StateT GameState IO.

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


Re: [Haskell-cafe] Is Hs-Plugins dead?

2007-05-01 Thread Stefan O'Rear
On Tue, May 01, 2007 at 09:51:37PM +0200, Philipp Volgger wrote:
 Is Hs-Plugins still under develeopment; is there still somebody who is 
 updating it?

Not really.  It works perfectly and fills its niche.  Mature software
is not under development! 

It is still maintained by Don Stewart.

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


Re: [Haskell-cafe] Cabal, lib and exe in one

2007-05-01 Thread Duncan Coutts
On Tue, 2007-05-01 at 22:29 +0100, Magnus Therning wrote:

 So if foo.hs is in test-src and Foo/Bar.hs is in src then I think you
 just need:
 
 hs-source-dirs: test-src, src
 
 No, that's not enough, I also have to add the following lines to make
 the executable compile and link:
 
   extensions: ForeignFunctionInterface
   c-sources: csrc/ptrace.c
 
 That is, I end up compiling the library a second time!  Can't I get the
 executable to link against the library that was just created?

 I was just expecting to not have to repeat myself in the cabal file.
 Not such a strange thing to expect from a build system, I think :-)

Yes this is an interesting question about what it means to have programs
in the same cabal package as an executable.

Currently having a executable and a library inside a cabal package is
not the same thing as having a library package and separate package that
contains only that executable. The difference is that when the
executable is in the same cabal package it merely has access to the same
modules, it doesn't 'depend' on that library package exactly. So for
example it can access modules which are not exposed by the library and
indeed it can compile those same modules with completely different build
flags. So currently those modules will be built twice.

It's not clear to me that this is the right meaning, or indeed that we
should allow multiple entries in a single .cabal file. I think it might
be better to just have multiple .cabal files (possibly in the same
directory). Then we could be explicit and state that an executable
depends on the library or if we want to use different build flags, or
use modules that are not exposed by the lib then we can do that and only
in that case do we build those modules twice.

 Also, I don't really see what you mean by that dir can be placed
 anywhere by the user.  That dir is created as part of the build
 process and it's location is, AFAICS, always going to be ./dist/build.

Actually it's location can be set at configure time with --scratchdir=
so that for example you could put it in a temp dir or something. 


Duncan

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


Re: [Haskell-cafe] Bloom Filter

2007-05-01 Thread ajb
G'day all.

Quoting Dom [EMAIL PROTECTED]:

 But better than what is in Codec.Utils:
[deletia]
 It seems a shame that everyone has to roll their own.

That and integer log base 2.

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


Re: [Haskell-cafe] Bloom Filter

2007-05-01 Thread ajb
G'day all.

I wrote:

  insert :: a - Bloom a - Bloom a
 
  That way, you can use it with foldr.

Quoting Josef Svenningsson [EMAIL PROTECTED]:

 Hmmm. If you want to create a Bloom using a fold wouldn't it make more
 sense to use foldl'? I think the argument order is fine.

You're right that foldl' makes more sense than foldr in this case.
Nevertheless, the usual Haskell convention is that insert-like functions
have the same argument order as the cons operator (:).

Haskell libraries have a real problem with the proliferation of
conventions for various things.  This order is the usual convention,
so follow it.  If you don't like it, there's always flip.

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


Re: [Haskell-cafe] Is Hs-Plugins dead?

2007-05-01 Thread Donald Bruce Stewart
pvolgger:
 Is Hs-Plugins still under develeopment; is there still somebody who is 
 updating it?

It's in stasis. It will likely get a little bit more updating when I
finish my phd.  It's needed for lambdabot in #haskell, so that's enough
pressure to keep it working :-)

For the longer term, a more maintainable approach is to provide an
hs-plugins api over the ghc-api, in my opinion. Then the bits of
hs-plugins that break when compiler versions change (.hi file parsing
and package file parsing), won't break.

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