Re: [Haskell-cafe] circular dependencies in cabal

2009-02-02 Thread allan

Hi

Are you still in a "not-able-to-do-a-cabal-install" state?
I had this problem as well and I solved it by simply deleting (or moving) my 
~/.ghc directory and then re-installing ghc, as per this message:

http://markmail.org/message/fraw3cw56squfeld

Note: that this should only be used if you can't solve it the suggested way 
which is to look in your pkg database for packages registered in both user and 
global databases and unregister the user one.

regards
allan


Valentyn Kamyshenko wrote:
So, in practical terms, you suggest that no new version of the package 
that ghc package depends on (directly or indirectly) should ever be 
installed?
For example, as soon as process-1.0.1.1 is installed on my computer, 
I'll have this problem with every package that depends on "process"?
Another question: would not cabal-install automatically fetch the most 
recent version of the "process" package, as soon as I will try to install

a package that depends on it (such as, for example, "plugins")?

-- Valentyn.

On Feb 1, 2009, at 6:53 AM, Duncan Coutts wrote:


On Sun, 2009-02-01 at 01:33 -0800, Valentyn Kamyshenko wrote:

Hello all,

when I tried to install plugins package with cabal, I've got the
following error:

# sudo cabal install plugins --global
Resolving dependencies...
cabal: dependencies conflict: ghc-6.10.1 requires process ==1.0.1.1
however
process-1.0.1.1 was excluded because ghc-6.10.1 requires process
==1.0.1.0


For the most part I refer you to:

http://haskell.org/pipermail/haskell-cafe/2009-January/054523.html

However the difference is that you've got this problem only within the
global package db rather than due to overlap in the global and user
package db.


It looks like both versions of process package are currently required:


It looks like you installed process-1.0.1.1 and then rebuilt almost
every other package against it. Of course you cannot rebuild the ghc
package but you did rebuild some of its dependencies which is why it now
depends on multiple versions of the process package.

Generally rebuilding a package without also rebuilding the packages that
depend on it is a bit dodgy (it can lead to linker errors or segfaults).
Unfortunately cabal-install does not prevent you from shooting yourself
in the foot in these circumstances.


Any suggestions?


Aim for a situation where you only have one version of the various core
packages. If you do not need to install packages globally then
installing them per-user means you at least cannot break the global
packages.

Duncan



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




--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: [Haskell-cafe] hmatrix, Windows and GCC

2009-01-28 Thread allan

Hi

The INSTALL file in the hmatrix repository has some very clear instructions for 
installation on Windows.
http://perception.inf.um.es/~aruiz/darcs/hmatrix/INSTALL

However note this section at the bottom:
"Unfortunately the lapack dll supplied by the R system does not include
zgels_, zgelss_, and zgees_, so the functions depending on them
(linearSolveLS, linearSolveSVD, and schur for complex data)
will produce a "non supported in this OS" runtime error."

Of course linearSolve is exactly what you will be wanting so this won't work 
for you.
I ran into exactly this problem myself. I actually didn't get as far as a 
run-time error as I got a linker error.

I don't have any solution for you though, sorry.

regards
allan



Rafael Gustavo da Cunha Pereira Pinto wrote:



   Hi all,

I am writing a program that uses hmatrix for solving some linear 
systems. The hmatrix package depends on BLAS, which, in turn, depend on 
GCC 4.2 to be built (at least ATLAS does).


GHC 6.10 for Windows is pre-packaged with GCC 3.4.5, and it leaves me 
with the impression that I would have incompatible ABIs.


My questions:

1) Why GHC 6.10 still uses GCC 3.4.5 in Windows? I know mingw considers 
GCC 4.2 to be alpha, but, lets face it, 4.2 is almost obsolete!
2) Is it possible to rebuild GHC 6.10, using Windows and GCC 4.2? Is 
there any guide for doing this?

3) Has any of you tried hmatrix on Windows? How did you do it?

Thanks,

Rafael

--
Rafael Gustavo da Cunha Pereira Pinto
Electronic Engineer, MSc.




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




--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: [Haskell-cafe] haddock question [solved]

2008-11-27 Thread allan
Ross Paterson wrote:
> On Thu, Nov 27, 2008 at 11:52:04AM +0000, allan wrote:
>> I'm trying to locally build the documentation for the haskell-src-exts 
>> package and running into a bit of bother.
>> If I run: cabal haddock
>> I get the error:
>> haddock: parse error in doc string
> 
> The problem is that several of the modules (not Language.Haskell.Exts,
> but modules it imports) have headers containing a field "Original"
> that haddock doesn't recognize.
> 

a ha, Thank you, that has fixed the problem.

regards
allan



-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


[Haskell-cafe] haddock question

2008-11-27 Thread allan
Dear all

I'm trying to locally build the documentation for the haskell-src-exts package 
and running into a bit of bother.
If I run: cabal haddock
I get the error:
haddock: parse error in doc string

so: cabal haddock -v
Doesn't really provide any extra information, it gives me the exact haddock 
command-line used but there is still no way (I can see) of obtaining the source 
file containing the parse error.

So I downloaded via darcs the latest haddock source code and installed that but 
I get the exact same error message.
I tried grepping in the haddock source code for that particular error message 
(and portions of it) but I couldn't find it.

Finally I tried running haddock on a single source file:
haddock Language/Haskell/Exts.hs 
and even this gets the exact same error message, which is somewhat bizarre 
since that file does not contain any documentation strings.

Anyone have any ideas?

regards
allan

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: [Haskell-cafe] Terminal-like Application Design

2008-10-17 Thread allan
Hi Jeff

It sounds like maybe you just want an application that works a bit like 'cabal'.
So with cabal the first argument is taken as the 'command' and then the rest 
are based on that:

cabal build --some other --options --which may --or --may --not have --arguments

Yi has a simple template for a script which should get you started, please find 
it attached.

So here instead of processOptions, you might want, processCommand

processCommand :: [ String ] -> IO ()
processCommand ("build" : args) = processBuildCommand args
processCommand ("play" : args)  = processPlayCommand args
processCommand []   = putStrLn "You must supply a command"
processCommand _= putStrLn "Sorry I don't understand your 
command" --Probably out put help here as well

processBuildCommand :: [ String ] -> IO ()
processBuildCommand = similar to the processOptions except now you are sure you 
are in a 'build' command

you *might* even have a separate set of option descreptions for each command.

hth
allan




Jeff Wheeler wrote:
> Hi,
> 
> I'm a slight Haskell newbie, but I'm trying to write a terminal-like
> application that accepts simple commands with optional arguments, and
> can then execute them. Most of these commands will need IO, as later I
> will want to communicate over USB for most of them.
> 
> I was hoping, though, that I could get some comments on the initial
> architecture I've been playing with [1].
> 
> I suspect I should be using some sort of monad to represent the
> commands, but I don't fully understand monads, and am not sure how it
> would apply in this context.
> 
> Should I be using a monad here, and if so, how?
> 
> Thanks in advance,
> Jeff Wheeler
> 
> [1] http://media.nokrev.com/junk/cli/
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

{-
-}
module Main
  ( main )
where

{- Standard Library Modules Imported -}
import System.Console.GetOpt
  ( getOpt
  , usageInfo
  , ArgOrder( .. )
  , OptDescr( .. )
  , ArgDescr( .. )
  )
import System.Environment
  ( getArgs
  , getProgName
  )
{- External Library Modules Imported -}
{- Local Modules Imported -}
{- End of Imports -}

data CliFlag =
CliHelp
  | CliVersion
  deriving Eq


options :: [ OptDescr CliFlag ]
options =
  [ Option   "h" [ "help" ]
(NoArg CliHelp)
"Print the help message to standard out and then exit"

  , Option   "v" [ "version" ]
(NoArg CliVersion)
"Print out the version of this program"
  ]

helpMessage :: String -> String
helpMessage progName =
  usageInfo progName options

versionMessage :: String -> String
versionMessage progName = 
  progName ++ ": This is version 0.001"

-- | The main exported function
main :: IO ()
main = getArgs >>= processOptions

processOptions :: [ String ] -> IO ()
processOptions cliArgs =
  case getOpt Permute  options cliArgs of
(flags, args, [])   -> 
  processArgs flags args
(_flags, _args, errors) -> 
  do progName <- getProgName
 ioError $ userError (concat errors ++ helpMessage progName)

-- We assume all of the arguments are files to process
processArgs :: [ CliFlag ] -> [ String ] -> IO ()
processArgs flags files
  | elem CliHelp flags= getProgName >>= (putStrLn . helpMessage)
  | elem CliVersion flags = getProgName >>= (putStrLn . versionMessage)
  | otherwise = mapM_ processFile files

-- Our processing of a file is to simply count the words
-- in the file and output the number as a line.
processFile :: FilePath -> IO ()
processFile file =
  do contents <- readFile file
 putStrLn (show $ length $ words contents)

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


Re: [Haskell-cafe] Libraries in home dir

2008-10-09 Thread allan
Hi,

In addition if you want to do this all or most of the time, that is there are 
few/no cabalised libraries you DO wish to install globally, then you can tell 
'cabal' to do this all the time by editing your ~/.cabal/config file. Here is 
mine:

repos: hackage.haskell.org:http://hackage.haskell.org/packages/archive
cachedir: "/home//.cabal/packages"
hackage-username: ""
hackage-password: ""
compiler: ghc
user-install: True
user-prefix: "/home//install/"

regards
allan


Dougal Stanton wrote:
> On Thu, Oct 9, 2008 at 2:08 PM, Mauricio <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I want to use a few libraries from hackage
>> and have already download and built them. Can
>> I install those libraries somewhere in my
>> home dir (I want to avoid installing as root)
>> so that ghc can find them?
>>
>> If so, which options should I give to Setup.hs
>> (with main=defaultMain) so that the libraries
>> are going to be copy to that dir?
> 
> Dpeending on whether you have (and are using) cabal-install, either
> 
> $ cabal install diagrams --prefix=$HOME --user
> 
> or
> 
> $ runhaskell Setup.lhs configure --prefix=$HOME --user
> 
> 
> That will (a) put the libraries etc in $HOME/lib and (b) register
> these packages locally.
> 
> Hope that helps!
> 
> 
> D
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


[Haskell-cafe] Re: [darcs-users] poll: how can we help you contribute to darcs?

2008-08-01 Thread allan
I would contribute to darcs if only

It didn't already do exactly what I want it to.

As you've said darcs is really good for small-to-medium sized projects, 
particularly with few developers.
Those are exactly the projects I happen to be working on. For my work I use 
darcs on a slightly larger project but with (mainly) only one developer (me). 
So basically because darcs works perfectly for me I have pretty little 
motivation to dive into the source code and 'fix' something which for me simply 
isn't broken.

regards
allan

Eric Kow wrote:
> Dear Haskellers,
> 
> I would like to take an informal poll for the purposes of darcs
> recruitment.  Could you please complete this sentence for me?
> 
>"I would contribute to darcs if only..."
> 
> The answers I am most interested in hearing go beyond "... I had more
> time".  For instance, if you are contributing to other Haskell/volunteer
> projects, why are you contributing more to them, rather than darcs?
> 

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: [Haskell-cafe] Problem compiling a CGI script that needs to write to file during its execution

2008-07-29 Thread allan
Hi

I had this same problem and I'm not sure my way is correct but I used 
'Control.Monad.Trans.liftIO'
Here is some code that I am using

{-
  The main program is pretty simple we just run the CGI action.
-}
main :: IO ()
main =  Cgi.runCGI $ Cgi.handleErrors cgiMain

{-
  To be able to produce graphs which we can then display in the output
  webpage we require that our main function, that is the one which creates
  the page be in the IO monad.
-}
cgiMain :: CGI CGIResult
cgiMain = 
  do visitInfo <- getAnalysisData
 page  <- Monad.Trans.liftIO $ createPage visitInfo
 Cgi.output $ Xhtml.renderHtml page

createPage :: Visit -> IO Html
createPage . blah stuff you don't care about

getAnalysisData :: CGI Visit

Visit is a data type I've made to hold the information obtained from the page.

Hope this helps
allan


Jefferson Heard wrote:
> Please ignore the obvious security holes, as this is not a script
> meant for public consumption, but some internal testing and
> prototyping.  I would like to write the result of my computation out
> to a file inside of cgiMain, but the type of the monad inside cgiMain
> is this odd CGIT IO CGIResult.  I tried using liftM on writeFile, but
> it then complained that "newanns" was a string instead of a list of
> strings, which I don't understand at all.  Here's the code:
> 
> DeleteAnnotation.hs:
> 
[snip code]

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: [Haskell-cafe] Qualified import syntax badly designed (?)

2008-07-09 Thread allan
Neil Mitchell wrote:
> Hi
> 
>> Just to say that I also like this design. A minor point would be; do we
>>  really need the parentheses and commas? or could we not just use
>>  indentation (I think this about module imports in general).
> 
[snip general agreement]
> 
> However, I think the new syntax for modules, and the new type of
> declarations for modules, are separate issues.

Sure!

> 
>>  Also I wouldn't mind 'as' for the names which are imported which would
>>  be a bit of a work around for the debate as to whether I should design
>>  my modules for qualified import or not. Suppose I make a 'NewList'
>>  module and use the default names then someone could do:
>>  import Data.NewList
>>   unqualified map  as nlMap
>>   find as nlFind
>>   lookup as nlLookup
> 
> I believe old versions of Haskell had this, and it was considered too
> confusing. Consider:
> 
> import Prelude unqualified (+) as (-)
> 
> Also people reading the code will find it easier to know N =
> Data.NewList (one mapping), than three mappings as you have.
> 

Yes I generally agree there, I don't think 'as' for imported names is
particularly important and if it's been tried before and found to be
confusing well then that pretty much settles it for me.
If I were particularly for it then I'd point out that:
import Prelude unqualified (+) as (-)
would only be written by someone with limited common sense or someone
trying to break things (but I'm sure you could come up with a more
realistic example).
More importantly for me is the consistency you mentioned, for me it
seems inconsistent that you can remap a module name but not an imported
identifier. That said, your point about knowing one or three mappings is
somewhat compelling and I'm now somewhat less in favour of 'as' for
imported names.

regards
allan

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: [Haskell-cafe] Qualified import syntax badly designed (?)

2008-07-09 Thread allan
Neil Mitchell wrote:
> Hi
> 
>> declaration with a regular syntax. For example:
>>
>> import Data.Map as Map
>> unqualified (Map, (\\))
>> qualified   (lookup, map, null)
>> hiding  (filter)
> 
> I think I prefer this to my proposal, plus its closer to the current
> syntax. I think its also nearly equal to what Tom Davie came up with,
> given some keyword renaming. If we dropped the unqualified keyword,
> and just required unqualified things to come directly after, we get
> the full benefits of not introducing any keywords.
> 
Just to say that I also like this design. A minor point would be; do we
really need the parentheses and commas? or could we not just use
indentation (I think this about module imports in general).

Also I wouldn't mind 'as' for the names which are imported which would
be a bit of a work around for the debate as to whether I should design
my modules for qualified import or not. Suppose I make a 'NewList'
module and use the default names then someone could do:
import Data.NewList
  unqualified map  as nlMap
  find as nlFind
  lookup as nlLookup

or vice-versa.

regards
allan

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


Re: [Haskell-cafe] Precedence and associativity in a pretty-printer

2008-01-22 Thread Allan Clark

Edsko de Vries wrote:

Hi,

Is there a nice way to pretty-print such an expression with the minimal
number of brackets? I can come up with something, but I'm sure somebody
thought hard about this problem before and came up with a really nice
solution :)

Any hints or pointers would be appreciated,

Thanks,

  

You might find Norman Ramsey's paper on unparsing helpful:

http://citeseer.ist.psu.edu/194913.html
or google for
Norman Ramsey Unparsing

regards
allan


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


[Haskell-cafe] Data.Binary and serialising doubles in IEEE format

2008-01-09 Thread allan

Dear all

I have what I think should be a relatively simple problem:
I have a C program which reads in data from a binary file, it is a 
specific format so it knows that there are 3 integers followed by three 
doubles or whatever. So I'm trying to serialise the data from within a 
Haskell program and write it out to a file such that the C program can 
read this.
I've gotten the integers to work no problem but I'm having difficulty 
with the doubles.


My method is to use the Data.Binary library to write the data out as a 
bytestring and then simply write this out to disk.
The problem is that the instance of Binary for  Double does not 
serialise the data in the format which is expected by the C program 
(standard IEEE format using fread and a cast).


Now there was a thread on (essentially) this very same topic on 
haskell-cafe back in April, see:

http://www.haskell.org/pipermail/haskell-cafe/2007-April/024596.html

There was some discussion about the 'right' thing to do and that the 
library intended to be split into two separate portions; one for users 
that wish to serialise their own data and have it readable by the same 
haskell program, and those that wish to communicate with programs 
written in other languages.


From the above thread:


Perhaps we just don't care about ARM or other arches where GHC runs that
do not use IEEE formats, I don't know. If that were the case we'd say
something like:

instance Binary Double where
  put d = assert (isIEEE (undefined :: Double)) $ do
write (poke d)


Now for my specific problem I'd be happy if I could write a function:
putDouble :: Double -> Put

and so obviously I tried:
putDouble :: Double -> Put
putDouble d = assert (isIEEE (undefined :: Double)) $ do
write (poke d)

However I seem to be stuck at this point, where does the 'write' 
function come from?


Essentially then, is there anyone that can write my 'putDouble' function 
or give some hint as to how I might do it.
For the moment assume that I'm not really concerned with portability 
across platforms at least for the time being (I certainly don't think 
that the C program I'm attempting to communicate with is particularly 
portable anyway).


kind regards
allan

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


Re: [Haskell-cafe] Am I blind?

2008-01-06 Thread Allan Clark




I've searched all over the place, and I can't find this information 
actually "announced" anywhere except on the GHC homepage itself. And 
yet, I've seen emails bouncing around that appear to be replies to the 
announcement email. But I can't find the actual announcement email 
anywhere. Am I going mad?



It was on just the Haskell rather than Haskell-cafe mailing list.
http://www.mail-archive.com/[EMAIL PROTECTED]/msg20759.html

regards
allan

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


Re: [Haskell-cafe] Call external program and get stdout

2007-11-24 Thread Allan Clark

Roberto Zunino wrote:

Allan Clark wrote:
  

-- Create the process
 do (_pIn, pOut, pErr, handle) <- runInteractiveCommand command
-- Wait for the process to finish and store its exit code
exitCode <- waitForProcess handle



Warning: this will get stuck if the command output is so big that it
fills the SO buffers. This limit is 64K here.

Regards,
Zun.
  
Ah thanks for the warning, I've never tested this on anything 
particularly large.


regards
allan

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


Re: [Haskell-cafe] Call external program and get stdout

2007-11-22 Thread Allan Clark

Jules Bean wrote:

Maurí­cio wrote:

Hi,

How can I call a program (like, for instance,
'grep text *') and get the standard output?
All actions I found (executeFile, system) do
not give me the output of the program.


http://haskell.org/ghc/docs/latest/html/libraries/process-1.0.0.0/System-Process.html 


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


I was using the following:
{-
 A small function for blindly running a process until it completes
 its output and then waiting for its exit code.
 We return both the output (excluding stderr) plus the exit code.
-}
getProcessOutput :: String -> IO (String, ExitCode)
getProcessOutput command =
-- Create the process
 do (_pIn, pOut, pErr, handle) <- runInteractiveCommand command
-- Wait for the process to finish and store its exit code
exitCode <- waitForProcess handle
-- Get the standard output.
output   <- hGetContents pOut
-- return both the output and the exit code.
return (output, exitCode)

You'll need the following imports:
import System.IO
 ( hGetContents )
import System.Process
 ( runInteractiveCommand
 , waitForProcess
 )
import System.Exit
 ( ExitCode ( .. ) )

regards
allan



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


Re: [Haskell-cafe] Yi pre-release

2007-04-06 Thread allan




Patches, comments, criticism welcome... as always!

-- Jean-Philippe Bernardy
  
I have a question, my compilation gets stuck on configure, it can't find 
package FilePath >=1.0
Which file path library is this? There are a few around, but I can't 
seem to find one with a version number greater than or equal to 1.0.


regards
allan

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


Re: [Haskell-cafe] How you can help improve Haskell implementations!

2007-02-26 Thread Allan Clark

Donald Bruce Stewart wrote:

Just a quick note to say that the Haskell implementation shootout is
progressing, now supporting jhc, fixing a range of bugs, and providing
more benchmark programs. Nice average numbers are also reported for the
relative performance of each compiler or interpreter.

On x86:
http://www.cse.unsw.edu.au/~dons/nobench/i686/results.html

On amd64:
http://www.cse.unsw.edu.au/~dons/nobench/x86_64/results.html

Several bugs in our beloved Haskell compilers have been spotted, and
most of them already fixed!
  

And also I guess the compilers will do more optimisations, etc.
So this suggests an obvious extra feature for nobench which would be the 
ability to view a graph of each compiler's performance over a period of 
time, obviously this probably wouldn't be useful for at least a few 
months. However in particular it would be very good for the compiler 
writers to be aware if the performance goes *down* that is a further 
release of a compiler causes a benchmarked program to run slower.


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


Re: [Haskell-cafe] Re: Is lazyness make big difference?

2007-02-15 Thread Allan Clark



i.e. to use Monad.Writer in stead of Monad.State. The point is that for
example 'typedProgram' does not really depend on the contents of 'log',
but the dependencies in your code don't express this. One should switch from

  Log -> (a, Log)

to

  (a, Log -> Log)

or even

  (a, Log)

if Log already has a natural monoid structure.
Yes of course you're quite right, in general I would have the last 
version ie (a, Log).
I did not wish to muddy the example, but probably it was not helpful to 
have 'typedProgram' depend on the contents of 'log'.


regards
allan


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


Re: [Haskell-cafe] Is lazyness make big difference?

2007-02-15 Thread Allan Clark

Nick wrote:

Hi all,

(Another topic stolen from a Russian forum discussion).

As everyone know, there are lot of strict languages, that have 
possibilities to "switch on" lazy evaluation when needed.


But the examples that I saw on Haskell, there was not much use of lazy 
evaluation, often there were just several lazy points, and the rest 
could be done strictly without loss of generality. For example, in 
finding primes:
I think the Haskell solution is more compact due to syntactic sugar, 
curring and "parentheses-free-ness", *not* lazy evaluation.



Hi,
   I think a big advantage is that programs can be written without 
regard for whether or not a value will in the long run actually be 
evaluated.
For me one of the best examples of this is that of logging within a 
compiler.

Consider a compiler which operates roughly as such

compileProgram :: String -> IO ()
compileProgram program =
 let (log, abstract) = parse program
  (log2, typedProgram) = typeCheck abstract log2
  (log3, convertedProgram) = convertToIntermediate typedProgram log2
  (log4, convertedToAssembly) = convertToAssembly convertedProgram log3
 in do writeFile "a.asm" (show convertedToAssembly)
  writeFile "a.log" (show log4)

Now each of the intermediate transforming calls will produce some 
logging information which is added to the current log.
Some of these will require quite heavy traversing of the entire program, 
which will almost certainly require auxiliary functions.

Suppose we want to allow the suppressing of the log information ie:

compileProgram :: String -> Bool -> IO ()
compileProgram program logOrNot =
 let (log, abstract) = parse program
  (log2, typedProgram) = typeCheck abstract log2
  (log3, convertedProgram) = convertToIntermediate typedProgram log2
  (log4, convertedToAssembly) = convertToAssembly convertedProgram log3
 in do writeFile "a.asm" (show convertedToAssembly)
  if logOrNot
  then writeFile "a.log" (show log4)
  else return ()

Now if this is a strict language we have to go and modify all the 
intermediate functions to first of all take in a boolean and then use 
that to decide whether or not to produce any logging information. With a 
lazy language though, we don't need to do that, we're already done, no 
logging information will be produced if 'logOrNot' is false, because it 
will never be forced to evaluate the thunk.


According to one guy's analogy: the Real World is strict - in order to 
drink tea, you have to put the cattle on the fire, wait until water 
boils, brew tea and then drink. Not the cattle is put on the fire, 
water boils and the tea is brewed when you take the empty cup to start 
drinking. :-)


Yes true, but you don't just boil up the kettle and brew the tea unless 
you have first asked if anyone actually wants tea.


The question is the following: how big the gap between strict 
languages with lazy constructs and Haskell? Does the default lazyness 
have irrefutable advantage over default strictness?


Thank you for the attention.

With best regards,
Nick.


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


Re: [Haskell-cafe] Command line prompt templates

2006-11-24 Thread Allan Clark

Dougal Stanton wrote:

I was trying to write my own equivalent to Don Stewart's mkcabal but
ended up getting sidetracked. I made some generalised prompts for use at
the command line and wanted to get some feedback on them.

The full code can be found at [1] but the basic summary is like this:
  

Hi,
I also have a small module for use in a project I'm writing which I use 
for command line 'asking', you can find the code at :

http://homepages.inf.ed.ac.uk/s9810217/software/fragments/Hask.hs
and I guess it's possible something there might be of use to you.

regards
allan

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


Re: [Haskell-cafe] Cabal in ghc 6.4.2

2006-07-30 Thread allan




Yes, Char is in the haskell98 package, the new name for Char is
Data.Char which exports a bit more. Either add haskell98 as a package,
or replace Char with Data.Char (which is in base), I'd recommend the
latter, but either should work.

Thanks

Neil

a ha, that works, thank you both very much, I can sleep easy now.

allan

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


Re: [Haskell-cafe] Cabal in ghc 6.4.2

2006-07-30 Thread allan



The Text.ParserCombinators.Parsec modules are in the parsec module.

  

build-depends:  base



Add parsec here:

build-depends:  base, parsec


The reason it works when you run it without -hide-all-packages is that
by default for convenience all packages are 'exposed'. That is they can
be used without explicitly having to specify them. However it was felt
that for distributing software, which is one of the main purposes of
Cabal, one should be fully explicit about the dependencies so that users
compiling on other machines know exactly what packages needed and don't
end up with mysterious import errors.

  

Yip this sounds like a good policy to me too.


Now it's true that Cabal could be a bit cleverer here and warn you
before it even starts compiling that you have not specified all the
right packages in the build-depends. At the moment however Cabal doesn't
have a proper imports chaser so it can't do this.

Duncan
  


Thanks very much for the response, however, adding "parsec" to the 
build-depends of the .cabal file now causes a slightly different error, 
and in fact this is the same error I get with my other project:

haskellprint$ ./Setup.hs  build
Preprocessing executables for haskellprint-0.1...
Building haskellprint-0.1...
Chasing modules from: Main.hs
Could not find module `Char':
 use -v to see a list of the files searched for
 (imported from ./Parser.hs)
haskellprint$


so basically I was expecting 'Char' to be in the 'base' package, I guess 
this is wrong?


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


[Haskell-cafe] Cabal in ghc 6.4.2

2006-07-30 Thread allan

Hello all,

(before I start I should say I'm relatively new (a few months) to 
haskell, so I'm not exactly savvy with the use of the compilers)


I have a problem using the cabal with version 6.4.2 of ghc, the same 
thing occurs with two projects which I wish to compile, I'll use the 
simplest one since the problem seems to be the same in both cases.
The program is a very simple printer thing for haskell the source of 
which you can download at:
http://homepages.inf.ed.ac.uk/s9810217/software/haskell_print/haskellprint.tar.gz 
<http://homepages.inf.ed.ac.uk/s9810217/software/haskell_print/haskell_print.tar.gz>

(but you probably won't need to, in order to diagnose this problem)

I wish to compile this with the sequence of commands:
./Setup.hs configure --user --prefix=/home/allan/install
./Setup.hs build

this works perfectly on version 6.4 of ghc,
however with version 6.4.2 I get the following error:

haskellprint$ ./Setup.hs  build
Preprocessing executables for haskellprint-0.1...
Building haskellprint-0.1...
Chasing modules from: Main.hs
Could not find module `Text.ParserCombinators.Parsec':
 use -v to see a list of the files searched for
 (imported from ./Parser.hs)
haskellprint$

Now if I run
haskellprint$ ./Setup.hs build --verbose


then I can see the command line used to compile the program which is:
/home/allan/install/bin/ghc -Idist/build -o 
dist/build/haskell_print/haskell_print --make -Wall -hide-all-packages 
-i -idist/build/autogen -i. -odir 
dist/build/haskell_print/haskell_print-tmp -hidir 
dist/build/haskell_print/haskell_print-tmp -package base-1.0 Main.hs


If I copy and paste this into the command line and remove the argument [ 
-hide-all-packages ]

then the program compiles fine.
So basically my question is: what am I doing wrong? I assume my problem 
is in the .cabal file, so I include the contents here:

name:   haskellprint
version:0.1
license:GPL
license-file:   LICENSE
author: Allan Clark
maintainer: [EMAIL PROTECTED]
build-depends:  base

executable: haskell_print
main-is:Main.hs
include-dirs:  
c-sources: 
other-modules: 
extra-libraries:
extensions:
ghc-options:-Wall


-- ghc-options: -fwarn-incomplete-patterns -fwarn-missing-fields
-- ghc-options:-prof -auto-all -Wall -fglasgow-exts -O 
-funbox-strict-fields -fasm -optl-Wl,-s


thanks in advance for any help.
allan

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