Re: [Haskell-cafe] Cross-compiling of GHC

2007-09-17 Thread Ian Lynagh
On Mon, Sep 17, 2007 at 07:32:53PM +0800, L.Guo wrote:
 
 I have toolchain for the targer system. Using which, I can
 compile on PC and run the program on the embed system.

This isn't something that anyone's ever done with GHC, to the best of my
knowledge. You'd probably have to get your hands dirty to make it work,
but if you get stuck we can try to help you.


By the way, GHC-specific questions are better asked on the
[EMAIL PROTECTED] mailing list.


Thanks
Ian

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


Re: [Haskell-cafe] Tiny documentation request

2007-09-10 Thread Ian Lynagh
On Sun, Sep 09, 2007 at 05:38:03PM +0200, Sven Panne wrote:
 On Sunday 09 September 2007 16:40, Andrew Coppin wrote:
  I have the following page bookmarked:
 
http://haskell.org/ghc/docs/latest/html/libraries/
 
  I'd like to ask 2 things.
 
  1. Would it be possible to make the *huge* list of package names at the
  top collapsable? (That way I don't have to scroll through several pages
  of uninteresting text to get to the bit I actually want.)
 
 What do you mean exactly with the *huge* list of package names? The 
 description list with the short textual descriptions of each package?

It's about a fifth of the page, I think, and it'll get larger
percentagewise as base breaks up more.

Also, on Debian systems, we add all installed libraries to this index,
so it gets even larger.

 I'd say 
 that this list is highly interesting to people unfamiliar with the package 
 structure, so it is good that it is there.

Is that really helpful? There isn't a mapping from package name to
modules, so I'm not sure what it buys you. I'm sure I've never looked at
it.

I'm interested in other opinions on this, as I planned to remove the
list from the Debian packages.

Would it be better to have a separate page with a package index,
containing the description of each package and a link to each of the
modules that it provides?


Thanks
Ian

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


Re: [Haskell-cafe] :, infix operator, infix constructor, et cetera

2007-08-26 Thread Ian Lynagh
On Sun, Aug 26, 2007 at 01:35:33PM +0100, Andrew Coppin wrote:
 Isaac Dupree wrote:
 
 Except that (for no particularly good reason) : is a reserved symbol 
 
 Really? That's interesting... AFAIK, according to the Report, it 
 shouldn't be.

It is; from http://haskell.org/onlinereport/syntax-iso.html

consym   -  (: {symbol | :})reservedop
reservedop   -  .. | : | :: | = | \ | | | - | - | @ | ~ | =

 I just tested. GHC won't let me, WinHugs will. Hmm...

Sounds like a WinHugs bug if you haven't enabled extensions.


Thanks
Ian

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


Re: [Haskell-cafe] is there a way to run tests at compile time using TH

2007-08-26 Thread Ian Lynagh
On Sun, Aug 26, 2007 at 01:20:52AM -0700, Alex Jacobson wrote:
 I'd like to have code not compile if it doesn't pass the tests.
 
 Is there a way to use TH to generate compiler errors if the tests don't 
 pass?

This should do it, in a different module to that which defines runtests:

$( case runtests of
   Success - return []
   Failure - error Tests failed
 )


Thanks
Ian

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


Re: [Haskell-cafe] Help using CGIT

2007-08-22 Thread Ian Lynagh
On Wed, Aug 22, 2007 at 01:27:00PM -0500, Rich Neswold wrote:
 
  newtype App a = App (ReaderT Connection (CGIT IO) a)
 deriving (Monad, MonadIO, MonadReader Connection)
 
 Unfortunately, when another module tries to actually use the monad, I
 get warnings about No instance for (MonadCGI App). I tried making an
 instance:
 
  instance MonadCGI App where
  cgiAddHeader = ?
  cgiGet = ?

You have three choices:

1:
Install the unportable (works in GHC, not sure about hugs, not in
anything else TTBOMK) cgi-undecidable package and import
Network.CGI.Undecidable.
instance MonadCGI App where
cgiAddHeader n v = App $ cgiAddHeader n v
cgiGet x = App $ cgiGet x
Here Network.CGI.Undecidable provides the instance for MonadReader. The
nice thing about this one is it'll keep working is you later add a
StateT, say.

2:
Provide an instance for ReaderT and an instance for App that uses it:
instance MonadCGI App where
cgiAddHeader n v = App $ cgiAddHeader n v
cgiGet x = App $ cgiGet x
instance MonadCGI m = MonadCGI (ReaderT c m) where
cgiAddHeader n v = lift $ cgiAddHeader n v
cgiGet x = lift $ cgiGet x
Here the individual bits will keep working if you add a StateT, but you
will also need to add a StateT instance.

3:
Provide a single instance for App that does the whole thing:
instance MonadCGI App where
cgiAddHeader n v = App $ lift $ cgiAddHeader n v
cgiGet x = App $ lift $ cgiGet x
This one you would obviously have to change if you added a StateT.

 I'm also disappointed that I had to break apart
 'runCGI' (by cut-and-pasting its source) because I couldn't make it
 believe my monad looked enough like MonadCGI.

runApp :: App CGIResult - IO ()
runApp (App a) =
bracket (connect host dbname user password)
disconnect
(\c - runCGI (runReaderT a c))



(the above is mostly untested, so it may be wrong in some details).


Thanks
Ian

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


Re: [Haskell-cafe] -f flag to runghc broken, or is it just me? (because trying switch elegantly between ghc 6.6 and ghc 6.7)

2007-08-22 Thread Ian Lynagh
On Wed, Aug 22, 2007 at 01:38:39PM -0400, Thomas Hartman wrote:
 
 $ runghc -f /usr/local/bin/ghc-6.6.1  arghandling-nice.hs
 
 does nothing.

Contrary to the usage message, you aren't actually allowed a space after
-f in 6.6.1 (but you are in 6.7). Use
runghc -f/usr/local/bin/ghc-6.6.1 arghandling-nice.hs
instead.


Thanks
Ian

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


[Haskell-cafe] Re: trouble building 6.7 on ubuntu

2007-08-16 Thread Ian Lynagh
On Thu, Aug 16, 2007 at 09:39:54AM -0400, Thomas Hartman wrote:
 
 The programs included with the Ubuntu system are free software;
 checking host system type... i686-pc-linux-gnu
 checking target system type... i686-pc-linux-gnu
 Which we'll further canonicalise into: i386-unknown-linux
 checking for path to top of build tree... ./configure: line 1433: cd: 
 utils/pwd:
  No such file or directory
 ./configure: line 1438: -v0: command not found
 ./configure: line 1441: utils/pwd/pwd: No such file or directory
 configure: error: cannot determine current directory

What commands are you running? Is the above the complete output?

 By the way I have also tried 
 
 darcs get http://hackage.haskell.org/trac/ghc
 
 but this dies about halfway through (in the patch 1s ) with libcurl 
 error 18 or libcurl error 404 depending on the phase of the moon.

You're probably best off downloading and untarring:

http://darcs.haskell.org/ghc-HEAD-2007-08-14-ghc-corelibs.tar.bz2

and then ./darcs-all pull -a to get up-to-date. These are --complete
repos.

Unfortunately we don't have a tarball that includes the extralibs at the
moment, so you'll still need to ./darcs-all --extralibs get them
(either partially or completely).

 I'm currently trying a build from darcs checkout with get --partial. If 
 this is the preferred way of doing a checkout

If you don't want to hack on it then --partial is prefered as it's
quicker and takes up less disk space.

 due to crapping out halfway issues

I don't know what's going on there.


Thanks
Ian

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


Re: [Haskell-cafe] howto install ghc-6.7.* ?

2007-08-12 Thread Ian Lynagh
On Sat, Aug 11, 2007 at 11:44:17AM +0200, Marc A. Ziegert wrote:
 
 those extralibs seem to be installed in
  /usr/local/lib/ghc-6.7.20070810/lib/
 but registered in
  ghc-6.7.20070810/driver/package.conf.inplace
 instead of
  /usr/local/lib/ghc-6.7.20070810/package.conf

Now fixed, thanks.

By the way questions about the HEAD are generally best sent to the
[EMAIL PROTECTED] list.


Thanks
Ian

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


Re: [Haskell-cafe] Infinity v0.1

2007-08-12 Thread Ian Lynagh

Hi Austin,

On Sat, Aug 11, 2007 at 11:13:38PM -0500, Austin Seipp wrote:
 
 (there is no darcs repo yet, although I have emailed someone about a
 possible account for darcs.haskell.org.)

http://community.haskell.org/admin/ is probably a better fit.


Thanks
Ian

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


Re: [Haskell-cafe] positive Int

2007-08-02 Thread Ian Lynagh
On Thu, Aug 02, 2007 at 12:17:06PM -0700, brad clawsie wrote:
 as far as i know, the haskell standard does not define a basic Int
 type that is limited to positive numbers.

Haskell 98 doesn't have such a type, no, but in today's libraries there
is Data.Word.Word. Operations like subtraction will just wrap around
when they would otherwise go negative, though (All arithmetic is
performed modulo 2^n).

 for example, 'length' returns an Int, but in reality it must always
 return a value 0 or greater. a potential counter-argument would be the
 need to possibly redefine Ord etc for this more narrow type...

The main worry I can see with doing that is, would you need to keep
explicitly converting between Int and Word? It might be possible to
convert enough things to Word that it doesn't matter.

You'd also break lots of programs, of course.


Thanks
Ian

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


Re: [Haskell-cafe] Strange behavior of executeFile

2007-07-29 Thread Ian Lynagh
On Sun, Jul 29, 2007 at 10:34:10AM -0700, Bryan O'Sullivan wrote:
 
 Simon Marlow was going to look into this problem a few months ago, but I 
 don't know if he's had a chance to.

It's fixed in the HEAD:
http://hackage.haskell.org/trac/ghc/ticket/724


Thanks
Ian

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


Re: Re : Re : [Haskell-cafe] Indentation woes

2007-07-26 Thread Ian Lynagh
On Thu, Jul 26, 2007 at 08:17:06PM -0400, anon wrote:
 
 but one could likewise dismiss the entire layout business as a
 needlessly complicated way to save a few keystrokes if one were so
 inclined.

The main point of layout, in my eyes, is to make code more readable.
It achieves this both by removing noise (i.e. {;}) and by forcing you to
align your code so it is clear (or at least clear/er/) what is going on.

It's also important that the rules are easily understood by programmers,
and easily implemented by Haskell implementations and tools.

The current rules aren't perfect. For example, they fail the last point.
I thought there was a Haskell' ticket about that, but I can't see it
now.


Thanks
Ian

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


Re: [Haskell-cafe] Weird ghci behaviour?

2007-07-20 Thread Ian Lynagh

Hi Dan,

On Fri, Jul 20, 2007 at 02:12:12PM -0700, Dan Piponi wrote:
 On Unix-like OSes:
 
 If I run ghc test.hs and then run ghci test.hs, ghci fails to load
 up my code. I have to touch test.hs and then run ghci. I can
 understand ghci refusing to recompile something it thinks it has
 already compiled. But it appears to refuse to load it into an
 interactive session - which is less useful. In fact, removing test.hi
 makes ghci work again.
 
 This is ghc 6.6. Anyone else seeing this?

Seems to work for me, on Linux/amd64:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.6
$ echo 'main = putStrLn Foo'  q.hs
$ ghc q.hs
$ ghci -v0 q.hs
Prelude Main main
Foo
Prelude Main

Can you please give a complete testcase for the problem you're seeing?
Also, exactly which OS/arch are you on?


Thanks
Ian

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


Re: [Haskell-cafe] List of authors happy to have work moved to theHaskell wiki

2007-07-14 Thread Ian Lynagh
On Sat, Jul 14, 2007 at 05:26:27PM +0100, Claus Reinke wrote:
 
 (if you post material 
 you may later want to use in your book, or interim results from your 
 research projects; remember, anything on the wiki is free for all, so 
 anyone could republish it if it ends up there..)?

(sorry if you already know this, just want to clarify. All AIUI, IANAL,
etc)

If you publish something under licence A, you still remain the copyright
holder, and can later also publish it under licence B. You can also
publish it combined with other material under licence B.

For example, if you were to write a couple of pages on type systems to
the haskell-cafe list, publish it under the Simple Permissive License,
you could still publish a book on Haskell, including your text on type
systems, under a more traditional proprietary licence. People would
still be able to copy (etc) your type systems text, but would not be
able to copy (etc) the other material in your book.

The same is true even if you published the text under one of the
so-called viral licences (e.g. GPL).

 why should we have to think about licensing at all?

If you want code you write to be distributed by Debian, for example,
then you need to license it appropriately.


Thanks
Ian

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


Re: [Haskell-cafe] Multiple instancing of functions with FFI

2007-07-13 Thread Ian Lynagh

Hi Darrell,

On Mon, Jul 09, 2007 at 05:48:47PM -0700, Lewis-Sandy, Darrell wrote:
 I am having trouble exporting multiple instances of a polymorphic function
 similar to the example in the Haskell 98 Foreign Function Interface 1.0
 addendum (page 6).  My specific code is below:

Thanks for the detailed bug report!

I've put it in the bug tracker here:
http://hackage.haskell.org/trac/ghc/ticket/1533
milestoned to be fixed in the next release, and also added a test to the
testsuite for it.

 foreign export stdcall addByte (+):: Int8-Int8-Int8
 foreign export stdcall addInt  (+):: Int16-Int16-Int16
 foreign export stdcall addLong (+):: Int32-Int32-Int32

In the mean time, as a workaround, you can use

addByte :: Int8-Int8-Int8
addByte = (+)
addInt  :: Int16-Int16-Int16
addInt  = (+)
addLong :: Int32-Int32-Int32
addLong = (+)

foreign export stdcall addByte addByte :: Int8-Int8-Int8
foreign export stdcall addInt  addInt  :: Int16-Int16-Int16
foreign export stdcall addLong addLong :: Int32-Int32-Int32


Thanks
Ian

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


Re: [Haskell-cafe] Maintaining the community

2007-07-13 Thread Ian Lynagh
On Fri, Jul 13, 2007 at 09:35:09AM +0100, Malcolm Wallace wrote:
 
 Yes, the sheer volume of posts is definitely becoming a problem (for me,
 at least).

The Haskell lists are quite peculiarly named; the haskell@ list is
pretty much what would be haskell-announce@ anywhere else, and
haskell-cafe@ what would be haskell@ elsewhere. A haskell-cafe@ list
elsewhere would probably be where the haskell@ people discuss things
which aren't actually related to Haskell (like e.g. the demon.local
newsgroup). I think the number of posts in the wrong place would be
lower if these were more conventionally named (although there aren't a
lot of them anyway).

I think it would make sense to:

* Rename haskell@ to haskell-announce@, and redirect mails from haskell@
  to haskell-announce@ for some period.

* After that, rename haskell-cafe@ to haskell@ in a similar manner.

* At any point, create [EMAIL PROTECTED]
  This would have the advantage that people might not be so intimidated
  at making their first post here, and posts wouldn't be answered with
  category theory or scary type extensions.
  The disadvantages are that it makes an artificial barrier (when is
  someone ready to post to haskell@ instead?) and it doesn't split the
  discussion up by topic (if you want to see all the discussion about X,
  you need to follow both lists so you have the same amount of mail to
  read).
  I'm not sure if this is a good idea.

* At any point, create topic-specific lists, e.g. a list for discussion
  type system extensions (not sure if that's a good one, as often an
  extension is the /answer/ to a question how do I do foo?).
  This needs people to work out which lists would allow us to make a
  significant dent to the haskell-cafe traffic.


Thanks
Ian, also drowning

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


Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Ian Lynagh
On Thu, Jul 05, 2007 at 06:08:45PM +0100, Duncan Coutts wrote:
 On Thu, 2007-07-05 at 17:51 +0100, Neil Mitchell wrote:
  
   - Found that on hackage, downloaded and built OK. Lots of scary
   warnings about happy, greencard etc, not being found during configure,
   but let's go on.
  
  I've complained about these before, although I don't think anyone
  considered doing anything about it.
 
 We know what needs to change, but it's not a trivial change.

If anyone's interested, this is the Cabal bug for it:
http://hackage.haskell.org/trac/hackage/ticket/132


Thanks
Ian

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


Re: [Haskell-cafe] Sparse documentation

2007-07-05 Thread Ian Lynagh

Hi Andrew,

On Wed, Jul 04, 2007 at 07:26:48PM +0100, Andrew Coppin wrote:
 
 Writing documentation for libraries is one way in which ordinary 
 Haskell users can really contribute to the Haskell community. It’s not 
 hard to do (grab the Darcs repo, type away), and it’s widely appreciated.
 
 How exactly do I get started?
 
 (Obviously I can't write the documentation for the monad transformers - 
 I don't know how they work yet! But I could have a go at splicing all 
 the Parsec goodness into the Haddoc pages...)

Get the latest source:

darcs get http://darcs.haskell.org/packages/parsec
cd parsec

Build the Cabal Setup program and configure the package:

ghc --make Setup
./Setup configure

Then actually update the documentation, in Text/ParserCombinators/...

Now run haddock:

./Setup haddock

and check that it looks reasonable. Open dist/doc/html/index.html in
your web browser and follow the relevant links.

It's probably also a good idea to check you haven't broken the code by
accident, i.e. test that it still builds:

./Setup build

If you are happy then record and send the patch:

darcs record
darcs send




If you think that the patch might be at all contentious then you should
follow the library submissions procedure instead of the last step:

http://www.haskell.org/haskellwiki/Library_submissions

but for just adding brief haddock docs that's probably overkill.




Thanks
Ian

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


Re: [Haskell-cafe] formatTime %Q not working

2007-06-29 Thread Ian Lynagh
On Thu, Jun 21, 2007 at 05:39:12PM +0300, Bit Connor wrote:
 
 now - getCurrentTime
 2007-06-21 13:48:44.298699 UTC
 formatTime defaultTimeLocale %s now
 1182433724
 formatTime defaultTimeLocale %Q now
 
 
 %q also always gives me an empty string.

It seems to work OK for me with GHC 6.6.1 and time 1.1.1. Can you please
give a complete testcase, and say which version of time you are using
and where you got it from?


Thanks
Ian

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


Re: [Haskell-cafe] Updating haskell.org robots.txt

2007-06-29 Thread Ian Lynagh
On Wed, Jun 27, 2007 at 09:42:29PM -0700, Justin Bailey wrote:
 
 Any feedback, let me know. Thanks!

Thanks for looking at this, Justin! Looks fine to me.


Ian

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


Re: [Haskell-cafe] Best idiom for avoiding Defaulting warnings with ghc -Wall -Werror ??

2007-06-25 Thread Ian Lynagh
On Fri, Jun 22, 2007 at 11:37:15AM -0700, Dave Bayer wrote:
 
z = r Prelude.^ 3

I don't know if (^) in particular is what is causing you problems, but
IMO it has the wrong type; just as we have
(!!) :: [a] - Int - a
genericIndex :: (Integral b) = [a] - b   - a
we should also have
(^)  :: (Num a) = a - Int - a
genericPower :: (Num a, Integral b) = a - b   - a
(or some other function name).

I've mentioned this before, but until
http://hackage.haskell.org/trac/haskell-prime/ticket/118
is resolved we don't know where to discuss it (the haskell-prime or
libraries list).


Incidentally, I am another person who wants to be warned when defaulting
happens because I don't want to actually use defaulting, but I would
have no objection to the warning being suppressed if someone has
explicitly given a default declaration (and thus, presumably, does
want to use defaulting).


Thanks
Ian

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


Re: [Haskell-cafe] Can't build Lambdabot

2007-06-18 Thread Ian Lynagh
On Mon, Jun 18, 2007 at 05:07:19PM +0200, Daniel Fischer wrote:
 
 Plugin.hs:46:7:
 Could not find module `Text.Regex':
   it is a member of package regex-compat-0.71, which is hidden
 
 which would be easy to fix if regex-compat-0.71 WERE hidden, bu it's NOT, 
 it's 
 definitely exposed.

You need to list it in the build-depends field in the .cabal file.


Thanks
Ian

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


[Haskell-cafe] Re: Darcs on Solaris x86

2007-06-16 Thread Ian Lynagh
On Fri, Jun 15, 2007 at 12:40:40PM +0200, Christian Maeder wrote:
 
 Download the new binary dist:
 http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/pc-solaris/versions/new-ghc-6.6.1-i386-unknown-solaris2.tar.bz2
 
 Ian, could you replace
 http://www.haskell.org/ghc/dist/6.6.1/ghc-6.6.1-i386-unknown-solaris2.tar.bz2
 ?

Thanks Christian, done!


Ian

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


[Haskell-cafe] Re: [darcs-devel] advice on GADT type witnesses needed

2007-06-15 Thread Ian Lynagh
On Thu, Jun 14, 2007 at 08:27:36PM -0700, Jason Dagit wrote:
 On 6/14/07, David Roundy [EMAIL PROTECTED] wrote:
 
 src/Darcs/Patch/Show.lhs:50:0:
 Quantified type variable `y' is unified with another quantified type 
 variable `x'
 When trying to generalise the type inferred for `showPatch'
   Signature type: forall x y. Patch x y - Doc
   Type to generalise: Patch y y - Doc
 In the type signature for `showPatch'
 When generalising the type(s) for showPatch, showComP, showSplit,
   showConflicted, showNamed
 make: *** [src/Darcs/Patch/Show.o] Error 1
 
 The relevant code is
 
 showPatch :: Patch C(x,y) - Doc
 showPatch (FP f AddFile) = showAddFile f
 ...
 showPatch (Conflicted p ps) = showConflicted p ps
 
 and the trouble comes about because of (in Core.lhs)
 
 data Patch C(x,y) where
 NamedP :: !PatchInfo - ![PatchInfo] - !(Patch C(x,y)) - Patch C(x,y)
 ...
 Conflicted :: Patch C(a,b) - FL Patch C(b,c) - Patch C(c,c)
 
 
 I would like to add that I've tried (and failed) to construct a
 minimal example that demonstrates the type check failure by simulating
 the relevant code above.  This makes me wonder if the problem is not
 in the obvious place(s).

Here's one:

module Q where

data Foo x y where
Foo :: Foo a b - Foo b c - Foo c c

--

module W where

import Q

wibble :: Foo a b - String
wibble (Foo x y) = foo x y

foo :: Foo a b - Foo b c - String
foo x y = wibble x ++ wibble y

6.6 and 6.6.1 say:

$ ghc -c Q.hs -fglasgow-exts
$ ghc -c W.hs

W.hs:7:0:
Quantified type variable `b' is unified with another quantified type 
variable `a'
When trying to generalise the type inferred for `wibble'
  Signature type: forall a b. Foo a b - String
  Type to generalise: Foo b b - String
In the type signature for `wibble'
When generalising the type(s) for wibble, foo
$ ghc -c W.hs -fglasgow-exts
$

i.e. you need to give the -fglasgow-exts flag when compiling W.hs.
An {-# OPTIONS_GHC -fglasgow-exts #-} pragma in Show.lhs fixes the real
thing too.

The HEAD is the same, except the error is:

W.hs:7:8:
GADT pattern match in non-rigid context for `Foo'
  Tell GHC HQ if you'd like this to unify the context
In the pattern: Foo x y
In the definition of `wibble': wibble (Foo x y) = foo x y

I suspect your problem in making a testcase was moving the GADT
declaration into the same file as the function, and thus needing to
compile it with -fglasgow-exts anyway.

I'm not sure if GHC's behaviour is what is expected though; Simon?


Thanks
Ian

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


Re: [Haskell-cafe] Template Haskell, information about data constructor types

2007-06-05 Thread Ian Lynagh
On Mon, Jun 04, 2007 at 10:45:30AM +0100, Neil Mitchell wrote:
 
 On 6/4/07, Simon Peyton-Jones [EMAIL PROTECTED] wrote:
 
  Perhaps you mean that reify doesn't work on type constructors?  (E.g. 
  reify ''Maybe).
 It should -- if you think it doesn't can you concoct a test case and 
 submit it?
 
 I'm not sure if I'm doing something wrong, as I haven't managed to get
 it working for any type constructors. A test case:
 
 ghci -fth
 Prelude :m Language.Haskell.TH
 Language.Haskell.TH $( reify (mkName Maybe) = error . show )

This works:
$( reify ''Maybe = runIO . print  [| 'c' |] )

(modulo printing the result 4 times due to
http://hackage.haskell.org/trac/ghc/ticket/1201)

I don't think your example is expected to work.


Thanks
Ian

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


Re: [Haskell-cafe] Language extensions [was: Memoization]

2007-05-29 Thread Ian Lynagh
On Tue, May 29, 2007 at 12:41:19PM -0400, Isaac Dupree wrote:
 Simon Peyton-Jones wrote:
  |  I wish the compilers would allow more fine grained switches on languages
  | extensions. -fglasgow-exts switches them all on, but in most cases I'm
  | interested only in one. Then typing errors or design flaws (like 'type
  | Synonym = Type', instead of wanted 'type Synonym a = Type a'; extended
  | instance declarations) are accepted without warnings.
  
  Yes, we have an open Trac feature request for exactly this.
 
 ticket # what?

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

 I would think that preferable to inventing lots of compiler flags is
 reusing some of the names from the LANGUAGE pragma, where practical.

Agreed, as discussed in
http://www.haskell.org/pipermail/cabal-devel/2007-March/000460.html

I've also just added a note from an offline discussion that we should
use shorter names than I suggest in the above URL, and make them the
primary/only names.


Thanks
Ian

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


Re: [Haskell-cafe] System.Timeout problems

2007-05-27 Thread Ian Lynagh
On Sun, May 27, 2007 at 01:32:40AM +0100, Neil Mitchell wrote:
 
 Sadly, it doesn't seem to work for me. Here are the tests I've been
 using, the results I get, and what I would have liked. All are GHC 6.6
 on Windows.
 
 -- TEST 1
 import System.TimeoutGHC
 
 main :: IO ()
 main = do
r - timeout (5 * 10^6) (putStrLn here)
print r
 
 Without -threaded:
 here  Just ()  wait 5 seconds
 
 Without -threaded:
 here  wait 5 seconds  Just ()
 
 So, either way, I get a 5 second delay - not something I want.

Works for me with 6.6.1 on Windows and Linux, e.g. on Windows:

$ ghc --make -threaded q.hs -o q
[1 of 2] Compiling TimeoutGHC   ( TimeoutGHC.hs, TimeoutGHC.o )
[2 of 2] Compiling Main ( q.hs, q.o )
Linking q.exe ...

$ time ./q
here
Just ()

real0m0.070s
user0m0.010s
sys 0m0.010s

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

 -- TEST 2
 import System.TimeoutGHC
 
 main :: IO ()
 main = do
r - timeout (length [1..]) (putStrLn here)
print r
 
 Now, with either -threaded, or without, it never terminates.

This is expected, as it looks at n before doing anything. I'm not sure
why it does so though; it would be nice if timeout just acted as if n
was positive and left other cases to the caller.


Thanks
Ian

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


Re: [Haskell-cafe] More on the random idea

2007-05-26 Thread Ian Lynagh
On Sat, May 26, 2007 at 08:12:13PM +0100, Andrew Coppin wrote:
 
 It's too large and complicated to use for small things. E.g., if you 
 want to just dash off a little something that needs to evaluate an 
 expression... Well, you can use the GHC API. But this is highly 
 nontrivial. You get the impression it was added later,

That's because it /was/ added later!

Concrete suggestions of changes to the API which would make it easier to
use are definitely welcomed; the GHC bug tracker is probably the best
place to put them. We'd much prefer to change the API to become easier
to use than for everyone to have to work around its idiosyncrasies.

 I don't know about Linux, but Hugs is currently hopelessly unstable on 
 Windoze.

Have you filed bugs in the hugs bug tracker?


Thanks
Ian

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


Re: [Haskell-cafe] GHC Hangs

2007-05-12 Thread Ian Lynagh
On Mon, May 07, 2007 at 10:43:04PM -0500, Josiah Manson wrote:
 
 problem? Maybe, but I still think the behavior feels like deadlock, because
 sometimes compilation hangs while sometimes it does not, and when it hangs
 there is no CPU usage.

Can you get ghc -v output of (a) it hanging and (b) it not hanging?
Does it hang with both -fvia-C and -fasm?


Thanks
Ian

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


[Haskell-cafe] Ignore

2007-05-12 Thread Ian Lynagh

Sorry, please ignore.

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


Re: [Haskell-cafe] Picking an architecture for a Haskell web app

2007-05-10 Thread Ian Lynagh
On Thu, May 10, 2007 at 06:13:16PM +0100, Neil Mitchell wrote:
 
  Also remember that evaluating an expression in Haskell is _really_
  hard!
 
 Really? Looks pretty damn simple to me...
 
 In that case I throw down the challenge of writing an interpetter that
 takes a Haskell syntax tree and evaluates it :)
 
 What is the value of show [] ? Remember that show ([] :: String) /=
 show ([] :: [Bool), so I can't see how you can drop the types and keep
 the semantics.

show [] by itself can't be evaluated even with type inference, though. A
more convincing example, IMO, is something like

class Foo a where
foo :: a - String

instance Foo Bool where
foo _ = Bool

instance Foo Char where
foo _ = Char

x :: String
x = foo (id $! (undefined :: Bool))

where to evaluate x you can't evaluate the argument to foo (in general
it might not terminate) in order to find out what type this instance of
foo needs to have..


Thanks
Ian

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


Re: [Haskell-cafe] Picking an architecture for a Haskell web app

2007-05-10 Thread Ian Lynagh
On Thu, May 10, 2007 at 07:24:51PM +0100, Andrew Coppin wrote:
 
 On the other hand, parsing Haskell input is intractably hard. Whitespace 
 actually matters, which makes the program to parse Haskell horrendusly 
 complex.

Do you know about the algorithm for converting Haskell source into
a whitespace-insignificant sublanguage?

It's in section 9.3 of http://haskell.org/onlinereport/syntax-iso.html


Thanks
Ian

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


Re: [Haskell-cafe] question about Data.Binary and Double instance

2007-04-22 Thread Ian Lynagh
On Wed, Apr 18, 2007 at 09:12:30PM -0700, David Roundy wrote:
 
 I just want to read in a file full of Doubles (written in binary format
 from C++)

Note that if you write double's from C++ then you need to read CDoubles
in Haskell and then realToFrac them (which will presumably be optimised
out in practice).

Or alternatively you can work with HsDouble's in C++.


Thanks
Ian

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


Re: [Haskell-cafe] question about Data.Binary and Double instance

2007-04-22 Thread Ian Lynagh
On Tue, Apr 17, 2007 at 11:42:40PM -0400, Brian Alliet wrote:
 
  Perhaps we just don't care about ARM or other arches where GHC runs that
 
 Are there really any architectures supported by GHC that don't use IEEE
 floating point? If so GHC.Float is wrong as isIEEE is always true.

The one most likely to be non-IEEE is ARM, which has a middle-endian
representation; to make it explicit, it's the middle case here
(FLOAT_WORDS_BIGENDIAN but not WORDS_BIGENDIAN):

#if WORDS_BIGENDIAN
unsigned int negative:1;
unsigned int exponent:11;
unsigned int mantissa0:20;
unsigned int mantissa1:32;
#else
#if FLOAT_WORDS_BIGENDIAN
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
unsigned int mantissa1:32;
#else
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
#endif
#endif

Does anyone know if that makes it non-IEEE?


Thanks
Ian

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


Re: [Haskell-cafe] Re: `Expect'-like lazy reading/Parsec matching on TCP sockets

2007-04-16 Thread Ian Lynagh

Hi Scott,

On Mon, Apr 09, 2007 at 10:03:55AM -0600, Scott Bell wrote:
 Have you got a complete (but preferably small) program showing the
 problem?

Great example, thanks!

Sorry for the delay in tracking it down.

 main :: IO ()
 main = do (_, h, _, p) - runInteractiveCommand telnet nyx.nyx.net
  t - hGetContentsTimeout h 15000
  print t  terminateProcess p

The input handle is being garbage collected and closed, so telnet is
exiting. Try:

main :: IO ()
main = do (hin, h, _, p) - runInteractiveCommand telnet nyx.nyx.net
 t - hGetContentsTimeout h 15000
 print t
 hClose hin
 terminateProcess p

Note that you can't do either the hClose or terminateProcess before you
have forced the whole string (which print does here). You might prefer
to pass hin and p to hGetContentsTimeout, and have it close/terminate
them just before the return .

 hGetContentsTimeout :: Handle - Int - IO String
 hGetContentsTimeout h t = do
  hSetBuffering stdin NoBuffering
  ready - hWaitForInput h t; eof - hIsEOF h  

You'll also need to remove the hIsEOF call from your code, or having
decided that nothing is ready it will then block, waiting to see if
there is an end of file or not.


Thanks
Ian

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


Re: [Haskell-cafe] k-minima in Haskell

2007-04-13 Thread Ian Lynagh
On Fri, Apr 13, 2007 at 07:32:20AM -0400, [EMAIL PROTECTED] wrote:
 
 Quoting Thomas Hartman [EMAIL PROTECTED]:
 
  Does that mean you can have the k minima in O(n) time, where n is
  length of list, which would seem to be an improvement?
 
 It's worth considering what the theoretical minimum is.
 
 You have n elements, and you need to locate a specific k-element
 permutation.  There are n! / (n-k)! such permutations.  You therefore
 need log(n! / (n-k)!) bits of information.
 
 A binary comparison provides one bit of information.  So the number of
 comparisons that you need to get that much information is:
 
   O(log(n! / (n-k)!))
 = O(n log n - (n-k) log (n-k))
 = O(n log (n/(n-k)) + k log (n-k))
 
 That looks right to me.  If k  n, then this simplifies to
 O(n + k log n), and if k is close to n, it simplifies to
 O(n log n + k).

Hmm, is something wrong with the following?:

Tuple each element with its position: O(n)
Find kth smallest element in linear time, as per [1]: O(n)
Filter list for elements = kth smallest: O(n)
Sort filtered list by position:   O(k log k)
map snd to get the positions: O(k)

Total: O(n + k log k)

(the filter step will take care of elements with the same value as the
kth smallest, as the filter is also comparing element positions when the
values are the same).


Thanks
Ian

[1] http://en.wikipedia.org/wiki/Selection_algorithm

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


Re: [Haskell-cafe] Re: `Expect'-like lazy reading/Parsec matching on TCP sockets

2007-04-07 Thread Ian Lynagh
On Fri, Apr 06, 2007 at 01:44:01PM -0600, Scott Bell wrote:
 Ooops! It seems that this doesn't behave well with a -threaded
 RTS. I get an EOF on handles that I know for a fact shouldn't
 be receiving them. It still works well without -threaded, but
 does anyone know why I'm getting this behavior?
 
 hGetContentsTimeout :: Handle - Int - IO String
 hGetContentsTimeout h t = do
   hSetBuffering stdin NoBuffering
   ready - hWaitForInput h t
   if (not ready) then return []
 else do
   c - hGetChar h
   s - unsafeInterleaveIO (hGetContentsTimeout h t)
   return (c:s)
 
 (I did add EOF checking, but all that did was return the end of the  
 list earlier than I wanted)

Have you got a complete (but preferably small) program showing the
problem?


Thanks
Ian

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


Re: [Haskell-cafe] Compiling GHC

2007-03-30 Thread Ian Lynagh
On Fri, Mar 30, 2007 at 04:36:32PM +1000, Chris Witte wrote:
 I'm tying to compile GHC under mingw (winxp with mingw no cygwin),
 
 Loading package base ... linking ... ghc.exe: unable to load package `base'
 ghc.exe:
 C:/msys/1.0/local/HSbase.o: unknown symbol `_gettimeofday'
 
 
 any ideas on what could be causing this.

What does

grep -i gettimeofday mk/config.h

say?

If HAVE_GETTIMEOFDAY is defined then either comment it out (between
running configure and running make), or work out why the configure test
is succeeding but it doesn't work when GHC tries to use it.


Thanks
Ian

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


[Haskell-cafe] Re: Why the Prelude must die

2007-03-25 Thread Ian Lynagh

I've submitted:

http://hackage.haskell.org/trac/haskell-prime/ticket/124

which I hope covers the essence of the result of this thread.


Thanks
Ian

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


[Haskell-cafe] Re: Why the Prelude must die

2007-03-25 Thread Ian Lynagh

[reply-to set; dropping libraries]

On Sun, Mar 25, 2007 at 04:33:51PM +0100, David House wrote:
 On 25/03/07, Ian Lynagh [EMAIL PROTECTED] wrote:
 I've submitted:
 
 http://hackage.haskell.org/trac/haskell-prime/ticket/124
 
 which I hope covers the essence of the result of this thread.
 
 I'd hate to have to import things like Data.Function for such trivial
 functions as (.) and ($)

You wouldn't have to import a number of different modules like
Data.Function, you could just import Prelude.

The only difference is that, for Real modules, you explicitly say that
you want the Prelude, rather than sometimes needing magic like

import Prelude ()


Thanks
Ian

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


Re: [Haskell-cafe] Performance Help

2007-03-24 Thread Ian Lynagh
On Sat, Mar 24, 2007 at 01:46:33PM +, Dominic Steinitz wrote:
 
 Thanks. I'm trying to build just SHA1 but I am getting the following linker 
 errors. Do you know what option I should be adding?
 
 [EMAIL PROTECTED]:~/sha11 ghc -o perfTest 
 perfTest.hs -iIgloo/darcs-unstable/src --make -lz
 Linking perfTest ...
 Igloo/darcs-unstable/src/FastPackedString.o: In function `r4Lk_info':
 (.text+0x34c): undefined reference to `utf8_to_ints'

You need to link with fpstring.o (which in turn you get by compiling
fpstring.c).


Thanks
Ian

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


Re: [Haskell-cafe] Rank-2-polymorphism problem

2007-03-23 Thread Ian Lynagh
On Fri, Mar 23, 2007 at 02:18:50PM +0100, Martin Huschenbett wrote:
 
 -- The type I want to get.
 readValue' :: Field - (forall s. SqlBind s = Maybe s) - Value
 
 -- First trial:
 readValue' fld s =
   if isJust s then readValue fld (fromJust s) else emptyValue fld

Is there a reason you don't want this?:

readValue' :: Field - Maybe (forall s. SqlBind s = s) - Value
readValue' fld s =
if isJust s then readValue fld (fromJust s) else emptyValue fld


Thanks
Ian

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


Re: [Haskell-cafe] Newbie: Is ‘type’ synonym hiding two much?

2007-03-22 Thread Ian Lynagh
On Thu, Mar 22, 2007 at 06:13:00PM +0300, Dmitri O.Kondratiev wrote:
 
 succeed :: b - Parse a b
 
 *Before looking at 'succeed' function definition* one may think that
 'succeed' is a function of *one* argument of type 'b' that returns object of
 type 'Parse a b'.
 
 Yet, function definition given in the book is:
 
 succeed val inp = [(val, inp)]

It's common to instead write this as

succeed :: b - Parse a b
succeed val = \inp - [(val, inp)]

so the definition fits the type signature better.

 1. Should I work every time as a macro translator when I just see *!any!*
 function declaration?

If you are going to be dealing with the actual definitions of something
like Parser then you do need to know what the synonym is, yes. Your
implementation should be able to help you, e.g. in ghci:

Prelude :i ReadS
type ReadS a = String - [(a, String)]
-- Defined in Text.ParserCombinators.ReadP

The main advantage of the synonym is when you are /using/ the Parser
library, so you can put Parser String's in sequence etc without needing
to know that internally they're implemented as a function.

 2. Should I search through main and imported modules for treacherous 'type'
 constructs?
 3. Where, in this case goes implementation abstraction principle? Why I must
 provide *all* the details about function argument type structure in order to
 understand how this function works?

If you want abstraction then you need to use newtype or data to declare
the type.

e.g. if you had

newtype Parser a b = Parser (a - [(b, [a])])

then

succeed :: b - Parse a b
succeed val inp = ...

would be rejected by the compiler. Instead you would have to write

succeed :: b - Parse a b
succeed val = Parser (\inp - ...)


Thanks
Ian

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


Re: [Haskell-cafe] Type synonym application

2007-03-19 Thread Ian Lynagh
On Sun, Mar 18, 2007 at 05:47:21PM +, C Rodrigues wrote:
 Type synonyms aren't applied as I would expect during kind checking.  
 What's going on here?
 
 type WithList a b = b [a]
 type FooPair a b = (b, a - b)
 
 -- error: `WithList' is applied to too many type arguments
 ints1 :: WithList Int FooPair [Int]
 ints1 = ([1], id)

That's caused by kind defaulting, as bulat said.

 -- error: `FooPair' is not applied to enough type arguments
 ints2 :: (WithList Int FooPair) [Int]
 ints2 = ([1], id)

Type synonyms must be fully applied, i.e. you must always have something
like:
(FooPair a Int)
in types, not just FooPair, (FooPair a) or (FooPair Char).

The reason is that otherwise you get type-level lambdas, and type
inference becomes undecidable.


Thanks
Ian

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


Re: [Haskell-cafe] Re: HS-Plugins 1.0 chokes on simple test, WinXP GHC-6.6

2007-03-17 Thread Ian Lynagh
On Fri, Mar 16, 2007 at 09:52:10PM -0700, Conal Elliott wrote:
 BTW, to get hs-plugins to build, I changed two lines in
 hs-plugins/configure.

As it happens, I sent Don a similar patch last night, so hopefully it'll
be fixed in darcs soon.

 First I tried tr -d '\n', but it didn't work, and I don't know why.

Because it's a \r you're trying to delete.

 On 3/16/07, Conal Elliott [EMAIL PROTECTED] wrote:
 
 I got hs-plugins to compile fine on  winxp, but now when I run it I get a
 crash with this message:
 
 c:/ghc/ghc-6.6/HSbase.o: unknown symbol `_free'
 
 Don mentioned this is a known problem.  Is it on anyone's todo list?

Not mine.


Thanks
Ian

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


Re: [Haskell-cafe] Newbie question: ghc search path for .c files

2007-03-16 Thread Ian Lynagh

Hi Seth,

On Fri, Mar 16, 2007 at 01:53:49PM -0500, Seth J. Fogarty wrote:
 
 : ghc -i/home/sfogarty/lib/lp_solve_5.5 mipFFI.c
 mipFFI.c:1:0:  lpkit.h: No such file or directory

ghc -I/home/sfogarty/lib/lp_solve_5.5 mipFFI.c

should work. If not, add -v to the commandline to see what it is doing.

 And another question while I am here: -package posix and -package lang
 don't seem to be included on my distribution of ghc.

They are gone now. Programs using them should be updated to use newer
libraries instead - which ones will depend on what you were using from
them.


Thanks
Ian

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


Re: [Haskell-cafe] Performance Help

2007-03-16 Thread Ian Lynagh
On Sun, Mar 11, 2007 at 08:18:44PM +, Dominic Steinitz wrote:
 I have re-written the sha1 code so that it is (hopefully) easy to see that it 
 faithfully implements the algorithm (see 
 http://www.itl.nist.gov/fipspubs/fip180-1.htm). Having got rid of the space 
 leak, I have been trying to improve performance.
 
 Currently, the haskell code is 2 orders of magnitude slower than the sha1sum 
 that ships with my linux.

I don't know if this is useful to you, but darcs has some SHA1 code that
IIRC is much closer to C's performance. It currently uses darcs' own
FastPackedString library, but porting it to ByteString should be fairly
easy.

See SHA1.lhs in http://www.abridgegame.org/repos/darcs-unstable

It might even be able to be made faster still by calling lower-level
functions than {shift,rotate}{L,R} directly.


Thanks
Ian

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


Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Ian Lynagh
On Tue, Mar 13, 2007 at 09:41:47PM +0300, Bulat Ziganshin wrote:
 
 Tuesday, March 13, 2007, 9:06:31 PM, you wrote:
 
  forkOS should work as well, assuming you have OS threads, like in linux 2.6.
  You should probably be using the -smp compiler flag and not the -threaded
  compiler flag, I'm guessing, and make sure that your +RTS arguments indicate
  that you want to use X total concurrent threads...
 
 there is no need to use any
 compiler flags, because now it is default.

You do need to use -threaded, it's not the default yet.

You might be confusing this with ghc itself being built with -threaded
by default. Also, there are plans to make -threaded on by default in the
future.


Thanks
Ian

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


Re: [Haskell-cafe] Literate haskell format unclear (implementation and specification inconsistencies)

2007-03-03 Thread Ian Lynagh
On Sat, Mar 03, 2007 at 12:18:44PM -0500, Isaac Dupree wrote:
 
 Here are some (String - Bool) to test lines during parsing.

I haven't looked at your definitions in detail, but I think they might
be easier to follow (and, ultimately, include in the report) if they
were written in a BNF style like the one used in the report.

I also think it would be good to have a Haskell spec (a testsuite would
also be good, but not in the report itself). I've had a quick go at
hacking one up (attached) - entirely untested, but ghci -Wall is happy.
If I'm lucky it might even match my answers earlier in the thread. It
should be easy to alter if we decide to use different answers instead.


Thanks
Ian


import Data.Char

main :: IO ()
main = do xs - getContents
  putStr $ unlines $ unlit BirdAllowed $ lines xs

data State = InCode | InBird | BirdAllowed | BirdNotAllowed
data LineType = BeginCode | EndCode | BirdTrack String | Blank | Normal

unlit :: State - [String] - [String]
unlit InCode [] = error File ended in a code block
unlit _  [] = []
unlit s (x:xs)
 = case (lineType x, s) of
   -- First deal with code blocks
   (BeginCode,InCode) - error Can't nest code blocks
   (BeginCode,_)  - unlit InCode  xs
   (EndCode,  InCode) - unlit BirdAllowed xs
   (EndCode,  _)  - error Closing non-existent code block
   (_,InCode) - x  : unlit InCode xs
   -- Now deal with bird tracks
   (BirdTrack _,  BirdNotAllowed) - error Bird track next to stuff
   (BirdTrack x', _)  - x' : unlit InBird xs
   (Normal,   InBird) - error Bird track next to stuff
   (Normal,   _)  -  unlit BirdNotAllowed xs
   (Blank,_)  -  unlit BirdAllowedxs

lineType :: String - LineType
lineType x
 | x `starts` \\begin{code} = BeginCode
 | x `starts` \\end{code} = EndCode
 | otherwise = case x of
   ('':x') - BirdTrack (' ':x')
   _ | all isSpace x - Blank
 | otherwise - Normal

starts :: String - String - Bool
x `starts` pref = case x `stripPrefix` pref of
  Just s
   | all isSpace s - True
   | otherwise - error (Trailing characters after  ++ pref)
  Nothing - False

-- I really need to get around to proposing this for the standard libraries
stripPrefix :: Eq a = [a] - [a] - Maybe [a]
xs `stripPrefix` [] = Just xs
[] `stripPrefix` _ = Nothing
(x:xs) `stripPrefix` (y:ys)
 | x == y = xs `stripPrefix` ys
 | otherwise = Nothing

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


Re: [Haskell-cafe] Build failed - hidden package ?

2007-03-01 Thread Ian Lynagh
On Tue, Feb 27, 2007 at 05:36:29AM +0100, Dunric wrote:
 
 Graphics/UI/SDL/Rotozoomer.hs:15:7:
 Could not find module `Foreign.C':
   it is a member of package base, which is hidden

This is normally caused by forgetting to include

build-depends: base

in a .cabal file. When cabal builds a package with GHC it hides all
packages and then only exposes those which are listed as dependencies.

If you are compiling by hand then add the
-package base
flag to the commandline.


Thanks
Ian

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


Re: [Haskell-cafe] Literate haskell format unclear (implementation and specification inconsistencies)

2007-03-01 Thread Ian Lynagh
On Wed, Feb 28, 2007 at 05:48:09PM -0500, Isaac Dupree wrote:
 
 Trying to implement literate haskell[*], I realized several
 ways in which the correct behavior for unliterating (especially with
 regard to errors) was unclear.  I have several cases which ghc, hugs
 and Haskell 98 have differing opinions on!  The Report as it stands
 is far from a clear and complete specification (and I didn't find
 anything in the Haskell' wiki/trac about literate haskell).

Hmm, some of this came up around the time the revised report was being
written:

http://www.haskell.org/pipermail/haskell/2001-December/008549.html
http://www.haskell.org/pipermail/haskell/2001-December/008550.html

but oddly doesn't seem to have been clarified in the report. We should
definitely make sure that Haskell' does so!

 1.[UnmatchedBegin]
 If a \begin{code} starts a section of code, is \end{code}
 _required_ before the end of the file?

I would say yes.

 2.[AfterBeginOrEnd/{BeginWhite,EndWhite,BeginPrint,EndPrint}]
 Can a line beginning \begin{code} or \end{code} have additional
 stuff on the end, where the directive is understood and the
 additional stuff is ignored?

I would say yesIffAdditionalStuffIsInvisible (although I wouldn't object
to no; trailing white space makes me sad).

And nothing may precede \begin{code} or \end{code}.

 3.[IgnoringStringLiterals/{A,B}]
 what does (ignoring string literals, of course) mean?
 that the following(A) makes str = string gap:end{code} and an
 unended code block(A), or that it makes an ended code block(B)?
 (A)-
 \begin{code}
 str = string gap:\
 \end{code}

I didn't follow your question, but I think that in order to allow
things to be nicely compositional

\begin{code}
str = string gap:\
\end{code}
\end{code}

should be rejected by the unlitter for having trailing characters
following \end{code}. Did that answer it?

 4.[ExtraBeginEnd/{ExtraBegin,ExtraEnd}]
 What happens if \begin{code} appears after another \begin{code}
 before an \end{code}; and what happens if an \end{code} appears
 without a code block previously having been started by a \begin{code}?
 stray end:
ghc, nhc98:[UNLIT_IGNORED (- probable successful compile)]
  hugs:[error \end{code} encountered outside code block]
 stray begin:
 ghc, nhc98:[UNLIT_IGNORED (- probable syntax error)]
   hugs:[error \begin{code} encountered inside code block]

I agree with hugs.

 5.[LexicalUnitAcrossLiterateComment/{StringGap,BlockComment}]
 Can lexical units jump across literate comment gaps?
 report, ghc, hugs, nhc98: yes...

I agree.

 ghc, hugs, nhc98: think it's a fine comment

I agree.

 I mention this because allowing these makes it complicated to preserve
 literate comments in a translation to .hs,

I don't have a problem with that; I unlit, not convertlit  :-)

Allowing them makes it easier to write an implementation in a
compositional style.

 because, other than cases
 like these, prefixing literate comment lines with --   works fine.[*]
 However, banning these could make processing that wants to report errors
 end up more complicated.  Maybe the report could/should say that it
 is not advisable, as it does for mixing '' and {code} styles?

I don't object to saying it is inadvisable.

 6.[TeXBirdtrack/]
 I understand that
 It is not advisable to mix these two styles in the same file.
 and the report doesn't even talk about how they mix, but now that
 I've gotten started on the implementation inconsistencies...
 Actually, despite the Report's advice against it, there seems to be
 a consensus on what the meaning of mixing the two styles is, which
 I'll describe below:
 
 Sensibly, ghc, hugs and nhc98 treat begin/end{code} lines as blank
 for the purposes of ''-style comment checking (which is that
 a code and a non-blank literate comment line can't be adjacent);
 this works:
 [TeXBirdtrack/NoLayout]
 module Main where
 {main = print str
 \begin{code}
 ;str = string}
 \end{code}

I don't have an opinion on whether or not this should be allowed as I
don't think you should do it anyway, but you are right that it should be
clearly defined.

 Note I didn't rely on the layout rule. This should work:
 [TeXBirdtrack/AlignedLayout]
 module Main where
  main = print str
 \begin{code}
   str = string
 \end{code}

Again no opinion, but should be the same answer as the previous one.

 As another example, this doesn't work, for the same reason
 that you can't start a line with '' in a .hs file:
 [TeXBirdtrack/Wrong]
 module Main where
  main = print str
 \begin{code}
  str = string
 \end{code}

Right, this should not be allowed.


Thanks
Ian

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


Re: [Haskell-cafe] haskell-art mailing list

2007-02-26 Thread Ian Lynagh
On Sat, Feb 24, 2007 at 12:47:19PM +0100, Henk-Jan van Tuyl wrote:
 
 Is this something for the list at
   http://haskell.org/mailman/listinfo

That's generated by mailman, and as far as I know can't be easily
altered.

 (Maybe this page could be moved to haskellwiki?)

Perhaps adding a list of links to Haskell-related-lists on
http://www.haskell.org/haskellwiki/Mailing_lists would be best?


Thanks
Ian

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


Re: [Haskell-cafe] Timezone Database Library

2007-02-05 Thread Ian Lynagh
On Fri, Feb 02, 2007 at 01:54:13PM +, Martin Percossi wrote:
 Hello, is there a haskell library that provides facilities to read and 
 use the tzfile format [1], or equivalent in Windows?

Not as far as I am aware.


Thanks
Ian

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


Re: [Haskell-cafe] Fractional sqrt

2007-01-22 Thread Ian Lynagh
On Mon, Jan 22, 2007 at 03:26:38PM +0200, Yitzchak Gale wrote:
 
 Can someone with access to darcs.haskell.org
 please fix this library? darcs get currently does not
 seem to work for it.
 
 http://darcs.haskell.org/numeric-quest/

I've fixed the permissions, although applying patches in the future
might break them again.


Thanks
Ian

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


Re: [Haskell-cafe] GHC performance of 64-bit

2007-01-18 Thread Ian Lynagh

Hi Pedro,

On Fri, Jan 05, 2007 at 05:51:43PM +, Pedro Baltazar Vasconcelos wrote:
 
 I noticed that GHC generates slower code on an Linux amd64 bit platform than 
 the 32-bit version on a cheaper 32-bit machine.
 CPUTime for running sieve of Erathostenes to generate 10,000 primes:

Is it possible to send us the actual code you were using please?


Thanks
Ian

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


Re: [Haskell-cafe] State separation/combination pattern question

2007-01-03 Thread Ian Lynagh

Hi Reto,

On Thu, Dec 21, 2006 at 10:11:22PM -0800, Reto Kramer wrote:
 
 I've tried to thread the two states (StateA and StateB) using a chain  
 of StateT ... StateT ..., but couldn't really make that work.

That is how I would write it; I have attached code for your example.

 It  
 seems rather arbitrary in this case which state to make the inner/ 
 outer one

The choice is indeed arbitrary.

 and depending on this ordering the lifts have to go with  
 one or the other set of store calls.

If you don't mind turning on overlapping and undecidable instances then
you don't need to manually lift things at all.


Thanks
Ian


{-# OPTIONS_GHC -fglasgow-exts
-fallow-overlapping-instances
-fallow-undecidable-instances #-}

import Control.Monad.Trans (MonadTrans) 
import Control.Monad.State (StateT, evalStateT, get, put, lift)

-- StateA

type StateA = [Integer] 

newtype MonadAT m a = MonadAT (StateT StateA m a)
deriving (Monad, MonadTrans)

class Monad m = MonadA m where
getA :: m StateA
putA :: StateA - m ()

instance Monad m = MonadA (MonadAT m) where
getA = MonadAT get
putA = MonadAT . put

instance (MonadTrans t, MonadA m, Monad (t m)) = MonadA (t m) where
getA = lift getA
putA = lift . putA

evalAT :: Monad m = MonadAT m a - StateA - m a
evalAT (MonadAT x) = evalStateT x

-- StateB

type StateB = [Integer] 

newtype MonadBT m a = MonadBT (StateT StateB m a)
deriving (Monad, MonadTrans)

class Monad m = MonadB m where
getB :: m StateB
putB :: StateB - m ()

instance Monad m = MonadB (MonadBT m) where
getB = MonadBT get
putB = MonadBT . put

instance (MonadTrans t, MonadB m, Monad (t m)) = MonadB (t m) where
getB = lift getB
putB = lift . putB

evalBT :: Monad m = MonadBT m a - StateB - m a
evalBT (MonadBT x) = evalStateT x

-- The program

type Monads = MonadBT (MonadAT IO)

main :: IO ()
main = do res - evalAT (evalBT exec []) []
  print res

exec :: Monads (StateA, StateB)
exec = do foo
  bar
  foo
  foo
  bar
  a - getA
  b - getB
  return (a, b)

foo :: MonadA m = m ()
foo = do st - getA
 putA (1 : st)

bar :: MonadB m = m ()
bar = do st - getB
 putB (2 : st)

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


Re: [Haskell-cafe] porting ghc

2007-01-01 Thread Ian Lynagh
On Sun, Dec 31, 2006 at 02:39:33PM +, Ian Lynagh wrote:
 
  http://haskell.org/ghc/docs/6.6/html/building/sec-porting-ghc.html

I've been reminded that the building guide is being moved to the wiki,
so http://hackage.haskell.org/trac/ghc/wiki/Building (in particular
http://hackage.haskell.org/trac/ghc/wiki/Building/Porting) is probably
the best to work from.


Thanks
Ian

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


Re: [Haskell-cafe] porting ghc

2006-12-31 Thread Ian Lynagh

Hi Brian,

On Mon, Dec 18, 2006 at 10:07:19PM -0800, Brian McQueen wrote:
 I was trying to get a ghc going in my shell account the other day and
 found that the data at
 http://haskell.org/ghc/docs/6.6/html/building/sec-porting-ghc.html
 didn't apply at all.
 
 The system is a netbsd alpha which turns up as alpha-unknown-netbsd
 through configure.
 
 I didn't find any configure.in to modify, but there is a config.guess.
 Is that what I'm supposed to modify?

It should say configure.ac; I've just updated the doc sources
accordingly. If you search for alpha in that file then you should find
the stanzas. Just copy/paste a similar one and update it for Alpha
NetBSD.


Thanks
Ian

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


Re: [Haskell-cafe] Stack, Heap and GHC

2006-12-16 Thread Ian Lynagh
On Fri, Dec 15, 2006 at 10:05:38AM +, Felix Breuer wrote:
 On Thu, 14 Dec 2006 15:31:54 -0800, David Roundy [EMAIL PROTECTED] wrote:
  
  main = do putStrLn strict foldl1
print $ foldl1' (\a b - a + 1) $ [1..largenum]
putStrLn lazy foldl1
print $ foldl1 (\a b - a + 1) $ [1..largenum]
 
 2) Let me see if I get this right. The strict version runs in constant
 space because in the expression
 
   (((1 + 1) + 1) ... + 1)
 
 the innermost (1 + 1) is reduced to 2 right away.

The strict version never creates the expression (((1 + 1) + 1) ... + 1).
It's easier to see with foldl':

foldl' (\a b - a + 1) 0 [1..3]
{ evaluates 0+1 = 1 }
 - foldl' (\a b - a + 1) 1 [2..3]
{ evaluates 1+1 = 2 }
 - foldl' (\a b - a + 1) 2 [3..3]
{ evaluates 2+1 = 3 }
 - foldl' (\a b - a + 1) 3 []
 - 3

 The lazy version first
 uses a huge amount of heap space by building the entire expression
 
   (((1 + 1) + 1) ... + 1)
 
 on the heap. The evaluation of this expression starts by placing the 
 outermost + 1 on the stack and continues inward, not actually reducing
 anything, before everything has been placed on the stack, which causes
 the overflow. Correct?

Right, foldl doesn't evaluate its argument as it goes, so it builds
(((0+1)+1)+1) (on the heap):

foldl (\a b - a + 1) 0 [1..3]
 - foldl (\a b - a + 1) (0+1) [2..3]
 - foldl (\a b - a + 1) ((0+1)+1) [3..3]
 - foldl (\a b - a + 1) (((0+1)+1)+1) []
 - (((0+1)+1)+1)

Now we need to evaluate (((0+1)+1)+1) to get the final answer. You can
imagine a simple recursive evaluation function which, in the call 
evaluate (((0+1)+1)+1)
recursively calls
evaluate ((0+1)+1)
which recursively calls
evaluate (0+1)
and it is this recursion that has a stack that overflows.


Thanks
Ian

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


Re: [Haskell-cafe] Fwd: Build failure on FC6, ghc66

2006-12-16 Thread Ian Lynagh

Hi Conrad,

On Mon, Dec 11, 2006 at 09:56:35AM +0900, Conrad Parker wrote:
 
 I received the following bug report from someone trying to build HOgg
 on Fedora Core 6 (FC6) with its ghc66 package. The build error is:
 
   Could not find module `Data.Map':
 it is a member of package base, which is hidden
 
 I've built HOgg on Debian unstable with its ghc6.6 package without
 problems. I know that non-base libraries have been separated out in
 the GHC 6.6 release. Is this problem FC6 specific or a bug in HOgg's
 cabal setup? any clues?

Did you comment out the GHC 6.4 Build-Depends: and uncomment the GHC 6.6
Build-Depends:? It sounds like you might have done the commenting out,
but not the uncommenting?


Thanks
Ian

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


Re: [Haskell-cafe] SMP support in GHC 6.6 on PPC Macs

2006-12-09 Thread Ian Lynagh
On Sat, Nov 25, 2006 at 11:28:13PM +, Ivan Tomac wrote:
 I've noticed that code compiled with -threaded doesn't like +RTS - 
 Nthread count as an argument.
 
 This seems to be the case with both the binary distribution of GHC  
 6.6 at www.haskell.org/ghc as well as the version I built from sources.
 
 I got rid of all the old versions of GHC on my system and ghc -- 
 version reports 6.6. So I'm guessing this is a bug?

PowerPC isn't listed as an arch that supports SMP, but I can't see a
reason why it shouldn't be. I've just pushed a patch adding it to the
list.


Thanks
Ian

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


Re: [Haskell-cafe] non-blocking Socket

2006-12-06 Thread Ian Lynagh
On Mon, Nov 13, 2006 at 12:44:05PM -0800, Donn Cave wrote:
 
 Threads, maybe?  Is blocking I/O seriously incompatible with the GHC
 threading model (or one of the models)?

The problem is that a blocking IO call would block all threads. We could
execute all such calls in their own OS thread, but that would be
expensive. There is a bug about not using blocking IO:
http://hackage.haskell.org/trac/ghc/ticket/724
but I don't think there's a plan for what to do instead yet.

 If I have external library
 functions that use socket I/O internally, e.g., an OpenLDAP interface,
 that's effectively the same as a blocking socket created in Haskell,
 so whatever problem with one is the same with the other, right?

The same problems occur, yes. If you want it to use an OS thread then
use the threadsafe safety modifier on the foreign import declarations.


Thanks
Ian

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


Re: [Haskell-cafe] Re: help with threadDelay

2006-12-04 Thread Ian Lynagh
On Wed, Nov 29, 2006 at 10:57:52AM +, Neil Davies wrote:
 
 In order to get low jitter you have to deliberately wake up early and
 spin - hey what are all these extra cores for! - knowing the
 quantisation of the RTS is useful in calibration loop for how much to
 wake up early.

Ah, I see. Timing how long a threadDelay 1 takes and subtracting that
from future threadDelays is probably the best answer.


Thanks
Ian

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


Re: [Haskell-cafe] known, I know: class contexts and mutual recursion

2006-12-04 Thread Ian Lynagh
On Wed, Nov 29, 2006 at 06:14:56PM +, Conor McBride wrote:
 
 Mmm.lhs:15:1:
   Contexts differ in length
   When matching the contexts of the signatures for
 foo :: forall (m :: * - *). (Monad m) = Thing - m Int
 goo :: Thing - (Maybe Int - Int) - Int
   The signature contexts in a mutually recursive group should all be 
 identical
 
 Poking about on the web, I got the impression that this was a known 
 infelicity in ghc 6.4 (which I'm using), due to be ironed out. However, 
 an early-adopting colleague with 6.6 alleges that foo-goo is still 
 poisonous.

You can compile it with 6.6 if you use -fglasgow-exts. It's not clear to
me whether this will always work, e.g. if you have higher rank types
floating around, but if it does then we should add a hint to the error;
Simon?

 I'm wondering what the story is. I mean, is there some nasty 
 problem lurking here which prevents the lifting of this peculiar 
 restriction?

I don't know either, but this sounds like a good thing to bring up for
Haskell' if no-one has already.


Thanks
Ian

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


Re: [Haskell-cafe] File locked unnecessarily

2006-12-04 Thread Ian Lynagh
On Sun, Dec 03, 2006 at 08:13:37PM +0100, Arie Peterson wrote:
 
 Does anyone know what could cause this locking and/or how to prevent it?

Nothing else springs to mind. Are you able to send an example that shows
the problem? (obviously the smaller the example, the better).


Thanks
Ian

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


Re: [Haskell-cafe] Re: help with threadDelay

2006-11-28 Thread Ian Lynagh
On Wed, Nov 22, 2006 at 03:37:05PM +, Neil Davies wrote:
 Ian/Simon(s) Thanks - looking forward to the fix.

I've now pushed it to the HEAD.

 It will help with the real time enviroment that I've got.

Lazy evaluation and GHC's garbage collector will probably cause
headaches if you want true real time stuff.

 Follow on query: Is there a way of seeing the value of this interval
 from within the Haskell program?  Helps in the calibration loop.

I don't follow - what interval do you want to know? You can't find out
how long threadDelay took, but the lower bound (in a correct
implementation) is what you ask for and the upper bound is what you get
by measuring it, as you did in your original message.


Thanks
Ian

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


Re: [Haskell-cafe] Difficult memory leak in array processing

2006-11-25 Thread Ian Lynagh

Hi Niko,

On Thu, Nov 23, 2006 at 12:11:43PM +0200, Niko Korhonen wrote:
 
 I have the following code whose purpose is to add dither (noise) to a given
 array. The code looks very straightforward but apparently it has a memory
 leak somewhere. Here I try to run the algorithm for an array of 10,000,000
 integers. Ten million unboxed strict integers should equal to 40MB which
 should pose no problems to any modern system. However, the program fails
 with a stack overflow error. I'm using GHC 6.6 on Windows with 1 GB of RAM.

I'm also unable to reproduce this. Can you tell us exactly what
commandline you are using to compile and run the program please?


Thanks
Ian

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


Re: [Haskell-cafe] searching haskell.org

2006-10-15 Thread Ian Lynagh
On Sun, Oct 15, 2006 at 08:37:19AM -0400, Tamas K Papp wrote:
 
 I noticed that searching on Haskell.org (using the Search feature at
 the bottom) doesn't work as I expected.  For example, searching for
 memoise produces no results.

This is searching haskellwiki.

 http://www.google.com/search?q=memoise+site%3Ahaskell.org produces 18
 hits.

This is finding hits outside the wiki.

 Is this intentional?

It's expected, but not exactly intentional. It's probably not worth
setting up a haskell.org search tool, but adding a form for doing a
search with something like google restricted to the site might be
useful.


Thanks
Ian

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


Re: [Haskell-cafe] Haskellers in London (UK)?

2006-10-15 Thread Ian Lynagh
On Sun, Oct 15, 2006 at 01:42:37PM +0100, Ben Moseley wrote:
 
 Just thought I'd send out a quick mail to see if there are any other  
 Haskellers based in London who might be interested in getting  
 together occasionally.

Did you see
http://www.haskell.org/pipermail/haskell/2006-October/018635.html
? Not quite London, but close. See
http://www.oxfordbus.co.uk/espress1.shtml or http://www.oxfordtube.com/
for public transport between London and Oxford.


Thanks
Ian

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


Re: [Haskell-cafe] Profiling CAFs (re-post)

2006-10-10 Thread Ian Lynagh
On Tue, Oct 10, 2006 at 01:31:58PM +0200, Matthias Fischmann wrote:
 
   What qualifies as constant applicable form, and why is it not
   labelled in a more informative way?

CAFs are, AIUI, things that are just values (i.e. things that don't take
an argument) that have been floated up to the top level.

Compiling with -caf-all might give you more useful information.
If that doesn't help then you might find it helpful to look at heap
profiles rather than just the normal profiler output.

   Why are there functions that inherit all of their (considerable)
   time and space consumption from elsewhere, but nothing in the
   list would allow for such a rich inheritage?

I didn't understand that. If it's possible to give a small example then
that might help?


Thanks
Ian

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


Re: [Haskell-cafe] Profiling CAFs (re-post)

2006-10-10 Thread Ian Lynagh
On Tue, Oct 10, 2006 at 05:21:52PM +0200, Matthias Fischmann wrote:
 
  Compiling with -caf-all might give you more useful information.
 
 Oops.  I thought i had that in my Makefile, but appearently i was
 wrong...  If I add it, this is what happens:
 
 $ ghc -prof -caf-all Main.hs -o Main  # (ghc 6.4)
 /tmp/ghc22775.hc:1475: error: redefinition of `Mainmain_CAF_cc_ccs'
 /tmp/ghc22775.hc:1470: error: `Mainmain_CAF_cc_ccs' previously defined here

Hmm, filed as http://hackage.haskell.org/trac/ghc/ticket/931


Thanks
Ian

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


Re: [Haskell-cafe] Re: Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-26 Thread Ian Lynagh
On Sat, Aug 26, 2006 at 10:15:17PM +0300, Misha Aizatulin wrote:
 Neil Mitchell wrote:
  *Main show $ A `And` A
  A And A
  
  For me, using GHCi 6.4.2 + Windows, I get:
  A `And` A
 
   I installed GHC 6.4.2 now (on Linux). It really does print A `And`
 A, but still doesn't read it. Would you agree that GHC doesn't conform
 to the Haskell Report here? In fact it seems to produce a Read instance
 with no valid input for it!

ghci on 6.4.2 Linux works for me:

*Main show (A `And` A) 
A `And` A
*Main read (show (A `And` A)) :: T
A `And` A

(recent 6.5 also seems fine).


Thanks
Ian

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


Re: [Haskell-cafe] Is id strict?

2006-07-30 Thread Ian Lynagh
On Sun, Jul 30, 2006 at 09:44:25AM +0100, David House wrote:
 
 I've seen two definitions of a 'strict function', which I'm trying to
 unite in my mind:
 
 1) f is strict iff f _|_ = _|_.
 2) f is strict iff it forces evaluation of its arguments.
 
 There is a large sticking point that in my minds seems to fit (1) but
 not (2): id.

If the value of (id x) is demanded then the value of x will always be
demanded. Therefore id is strict in its first argument.

If x is _|_ then this implies the result of f x will also be _|_, as per
the f is strict = f _|_ = _|_ half of your 1).
f _|_ = _|_ = f is strict is not true, e.g. for f _ = f 'a'.

In place of your 2), I would say
(f x0 .. xn) is strict in xi if demanding the value of (f x0 .. xn)
requires demanding the value of xi.

(demanding the value in the above means evaluating to weak head normal
form).

Hope that helps.


Thanks
Ian

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


[Haskell-cafe] Re: Packages and modules

2006-07-05 Thread Ian Lynagh
On Wed, Jul 05, 2006 at 01:03:01AM +0100, Brian Hulley wrote:
 Simon Peyton-Jones wrote:
 Concerning other mail on this subject, which has been v useful, I've
 revised the Wiki page (substantially) to take it into account.
 http://hackage.haskell.org/trac/ghc/wiki/GhcPackages
 
 Further input (either by email or by adding material to the Wiki)
 would be welcome.  (No guarantee Simon M agrees with what I've
 written... I'm at home this afternoon :-)
 
 I think the following is a non-question:
 
  An open question: if A.B.C is in the package being compiled,
  and in an exposed package, and you say import A.B.C,
  do you get an error (ambiguous import), or does the current
  package override.
 
 because if the suggested syntax is used, import directives come in two 
 flavours: ones that use from to import from a different package and ones 
 that don't use from and therefore must refer to the current package.

FWIW this isn't what I actually intended when I was talking about using
from. I was imagining it would work similar to how foo unqualified
can refer to either an imported variable or a variable in the current
package, but we can still qualify Foo.foo should we wish to be
explicit. So you can import from any package, including the current
one, but qualify from package import should you wish to be explicit.

 (modified to use quotes):
 
from base

I think I missed where the plan to use quotes came from. What's the
purpose? Package names already have a well-defined syntax with no spaces
or other confusing characters in them, so why do we need the quotes? Or
is it just so we can have packages with the same name as keywords? (if
so I think personally I'd prefer a slightly more context-sensitive
grammar, not entirely unlike the as/qualified/hiding semi-keywords in
import statements).

import Predude hiding(length)
import Control.Exception
import qualified Data.List as List
 
 since otherwise it would soon become a bit of a pain to have to type 'from 
 base' everywhere (esp if the package name was some long URL). It would 
 also make it easier to quickly change to a different package without having 
 to modify multiple import directives, which might be especially useful in 
 the context of using a debug or release version of a package by putting C 
 pre-processor directives around the from part.
 
 There is a minor open question about the exact indentation rule for the 
 above syntax since base is not a keyword and it would seem strange to 
 desugar it into from {base; import ... } so it looks like it would need a 
 special layout rule that would give a desugaring into from base {import 
 ...}

It would only be slightly different to the current rules (it would be if
the second lexeme after from was not '{', rather than the first),
although now you mention it this would be an alternative possibility:

from base import
Prelude hiding (length)
Control.Exception
qualified Data.List as List

where import behaves much like of as far as the layout rule is
concerned.


Thanks
Ian

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


Re: [Haskell-cafe] Re: [haskell] ANNOUNCE: HNOP 0.1

2006-07-05 Thread Ian Lynagh
On Fri, Jun 30, 2006 at 03:45:57PM -0700, mvanier wrote:
 
 I'm at a loss here.  Somehow, the SplitObjs option doesn't seem to be doing 
 the job.  Any suggestions would be appreciated.

It looks like gcc 4.1 is floating all the

 __asm__(\n__stg_split_marker:);

results to the top of the file, so the splitter sees only a number of
empty sections followed by one large one. Results of

echo 'module Foo where'  Foo.hs
for i in `seq 1 10`; do echo foo$i = 'c'  Foo.hs; done
mkdir Foo_split
ghc -O -split-objs -c Foo.hs -v -keep-tmp-files

are attached, using

$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v 
--enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo 
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr 
--with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060613 (prerelease) (Debian 4.1.1-5)

Amd64 doesn't seem to be afflicted.


Thanks
Ian

[EMAIL PROTECTED]:~/debug$ ghc -O -split-objs -c Foo.hs -v -keep-tmp-files
Glasgow Haskell Compiler, Version 6.4.2, for Haskell 98, compiled by GHC 
version 6.4.2
Using package config file: /usr/lib/ghc-6.4.2/package.conf
Hsc static flags: -static -fglobalise-toplev-names
*** Checking old interface for Foo:
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size = 50
*** Simplify:
Result size = 30
Result size = 30
*** Specialise:
Result size = 30
*** Float out (not lambdas, not constants):
Result size = 30
*** Float inwards:
Result size = 30
*** Simplify:
Result size = 30
*** Simplify:
Result size = 30
*** Simplify:
Result size = 30
*** Demand analysis:
Result size = 30
*** Worker Wrapper binds:
Result size = 30
*** GlomBinds:
*** Simplify:
Result size = 30
*** Float out (not lambdas, constants):
Result size = 30
*** Common sub-expression:
Result size = 21
*** Float inwards:
Result size = 21
*** Simplify:
Result size = 21
*** Tidy Core:
Result size = 21
*** CorePrep:
Result size = 21
*** Stg2Stg:
*** CodeGen:
*** CodeOutput:
*** C Compiler
gcc -x c /tmp/ghc26801.hc -o /tmp/ghc26801.raw_s -DDONT_WANT_WIN32_DLL_SUPPORT 
-fno-defer-pop -fomit-frame-pointer -fno-builtin -DSTOLEN_X86_REGS=4 
-ffloat-store -fno-strict-aliasing -v -S -Wimplicit -O 
-D__GLASGOW_HASKELL__=604 -DUSE_SPLIT_MARKERS -I . -I /usr/lib/ghc-6.4.2/include
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v 
--enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo 
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr 
--with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060613 (prerelease) (Debian 4.1.1-5)
 /usr/lib/gcc/i486-linux-gnu/4.1.2/cc1 -quiet -v -I . -I 
/usr/lib/ghc-6.4.2/include -DDONT_WANT_WIN32_DLL_SUPPORT -DSTOLEN_X86_REGS=4 
-D__GLASGOW_HASKELL__=604 -DUSE_SPLIT_MARKERS /tmp/ghc26801.hc -quiet -dumpbase 
ghc26801.hc -mtune=i686 -auxbase-strip /tmp/ghc26801.raw_s -O -Wimplicit 
-version -fno-defer-pop -fomit-frame-pointer -fno-builtin -ffloat-store 
-fno-strict-aliasing -o /tmp/ghc26801.raw_s
ignoring nonexistent directory /usr/local/include/i486-linux-gnu
ignoring nonexistent directory 
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../i486-linux-gnu/include
ignoring nonexistent directory /usr/include/i486-linux-gnu
#include ... search starts here:
#include ... search starts here:
 .
 /usr/lib/ghc-6.4.2/include
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.1.2/include
 /usr/include
End of search list.
GNU C version 4.1.2 20060613 (prerelease) (Debian 4.1.1-5) (i486-linux-gnu)
compiled by GNU C version 4.1.2 20060613 (prerelease) (Debian 4.1.1-5).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129565
Compiler executable checksum: 3efbb0b5b3119ec825babd3e1cecb910
*** Mangler
/usr/lib/ghc-6.4.2/ghc-asm /tmp/ghc26801.raw_s /tmp/ghc26801.split_s 4
*** Splitter
/usr/lib/ghc-6.4.2/ghc-split /tmp/ghc26801.split_s /tmp/ghc26801.split 
/tmp/ghc26801.split
*** Assembler
gcc -c -o Foo_split/Foo__1.o /tmp/ghc26801.split__1.s

/* GHC_PACKAGES base-1.0 rts-1.0
*/
#include Stg.h
#include HsBase.h
__STG_SPLIT_MARKER
EI_(GHCziBase_Czh_static_info);
StgWord Foo_foo10_closure[] = {
(W_)GHCziBase_Czh_static_info, 0x63U
};
__STG_SPLIT_MARKER
EI_(Foo_foo9_info);
StgWord Foo_foo9_closure[] = {

Re: [Haskell-cafe] Packages and modules

2006-06-26 Thread Ian Lynagh
On Mon, Jun 26, 2006 at 04:20:16PM +0100, Brian Hulley wrote:
 
 I don't think this solves the whole problem. Suppose M1 needs to use A.B.C 
 from P1 *and* A.B.C from P2

For a simple example of a case where this might arise, suppose M1 is the
migration module for data (stored in a database, received over a
network, or some other such case) in P version 1's format to P version
2's format.

 [from wiki]
 import Packages.Gtk-1_3_4.Widget.Button

I'm also not a fan of this magic Packages.* hierarchy, nor the package
name change hoops it makes us jump through.

   package gtk-1_3_4 as Gtk
 or
   package gtk as Gtk -- use the current version of gtk
 or
   if package directive is omitted an import Xyz/Mod is equivalent to:
 
 package xyz as Xyz -- initial letter capitalised
 import Xyz/Mod

The package gtk as Gtk bit makes sense to me, but I'd expect then to
use Gtk.Foo.Bar for module Foo.Bar in package Gtk.

import gtk-1.3.4/Foo.Bar also makes sense, although personally I'd
prefer the syntax

from gtk-1.3.4 import Foo.Bar

where either from packagename is an optional prefix to current
import declaration syntax, or from packagename starts a block so we
can say

from gtk1
import Foo.Bar  as Gtk1.Foo.Bar
import Baz.Quux as Gtk1.Baz.Quux
from gtk2
import Foo.Bar  as Gtk2.Foo.Bar
import Baz.Quux as Gtk2.Baz.Quux

If we have gtk-1.something and gtk-2.something (rather than
gtk1-version and gtk2-version as above) then we'd probably instead want
the wiki's

-package gtk-2.0.1=Gtk2

which could be generated due to a .cabal build-depends of

gtk (= 2) as Gtk2


Thanks
Ian

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


Re: [Haskell-cafe] Re: Space usage problems

2006-01-17 Thread Ian Lynagh

Hi Bulat,

On Wed, Jan 18, 2006 at 12:10:45AM +0300, Bulat Ziganshin wrote:
 
 Monday, January 16, 2006, 12:52:42 AM, you wrote:
 
 IL OK, I have one library which provides
 
 IL inflate :: [Word8]   -- The input
 IL - ([Word8], -- A prefix of the input inflated (uncompressed)
 IL [Word8]) -- The remainder of the input
 
 you can use strict state monad for this task.

But then none of the output would be available until all the input was
consumed, right?

 in particular, looking at your code in MissingH 0.13, i recommend you
 try to use DiffUArray instead of Array

The code in missingh is old, entirely unoptimised and quite possibly
slightly buggy, incidentally.


Thanks
Ian

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


Re: [Haskell-cafe] Re: Space usage problems

2006-01-15 Thread Ian Lynagh
On Wed, Jan 11, 2006 at 03:00:45PM +, Simon Marlow wrote:
 Ian Lynagh wrote:
 On Wed, Jan 11, 2006 at 10:36:47AM +, Simon Marlow wrote:
 
 My suggestion: don't use the lazy state monad if you can help it.
 
 But a strict state monad would force everything to be loaded into memory
 at once, right?
 
 What would you suggest I use instead?
 
 I'm not sure - can you describe exactly what you want to do from a 
 higher level?  It might help to re-think the problem from the top down.

OK, I have one library which provides

inflate :: [Word8]   -- The input
- ([Word8], -- A prefix of the input inflated (uncompressed)
[Word8]) -- The remainder of the input

I can't tell how much of the input I'll be inflating in advance, I only
know when I reach the end of the compressed part.

Inflating has an array and a few other bits of state while it
uncompresses the input.

(I'm assuming the inflation won't fail for now; later I might want
something like
inflate :: [Word8]   -- The input
- ([Word8], -- A prefix of the input, inflated (uncompressed)
[Word8], -- The remainder of the input
Bool)-- Inflation failed
where you would need to write the inflated data to a file, say, before
checking the Bool to see if there was an error (if you want to work in
constant space)).

I'm happy to have a different type for inflate if necessary (e.g.
inflate :: m [Word8] - ([Word8] - m ()) - m [Word8]
where inflate uses the Monad of the caller to read and write the
remaining input; this leads to something using a monad transformer
for inflates other state, along the lines of Test2 in my original
message, which lead to a stack overflow) but it shouldn't be wedded to
the following library:


I then have another library with a function that does:

while (some input left)
read header
call inflate
read footer
return (concat all the inflate results)

Reading headers is a fiddly enough task that passing the input around by
hand is undesirable.


Thanks
Ian

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


Re: [Haskell-cafe] Re: Space usage problems

2006-01-11 Thread Ian Lynagh
On Wed, Jan 11, 2006 at 10:36:47AM +, Simon Marlow wrote:
 
 My suggestion: don't use the lazy state monad if you can help it.

But a strict state monad would force everything to be loaded into memory
at once, right?

What would you suggest I use instead?

Or do I just have to tread carefully to keep this optimisation happy
until the GCer is improved?


Thanks
Ian

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


[Haskell-cafe] Space usage problems

2006-01-10 Thread Ian Lynagh

Hi all,

I am having space issues with some decompression code; I've attached a
much simplified version as Test1.hs.

At the bottom (foo/bar) is the equivalent of deflate. This should be a
standalone module which doesn't know about the rest.

In the middle (readChunks) is the equivalent of gunzip. It repeatedly
calls foo until there is no more input left.

At the top is a simple main function that calls them.

If I do

dd if=/dev/zero of=data bs=1000 count=3000 # making data around 3MB
ghc --make Test1 -o Test1 -O -Wall
./Test1

then in top I see Test1 increasing memory usage to around 150MB. I think
this is because the let (ys, zs) = foo xs means zs holds on to xs
(it's hard to be sure as compiling for profiling is too happy to change
the behaviour).

I tried (Test2) changing foo to be a monad transformer over the calling
monad, so the caller's remaining input was updated as we went along, but
(as well as memory usage not obviously being fixed) this is giving me a
stack overflow.


Has anyone got any suggestions for making a constant space, constant
stack version?


Thanks
Ian


module Main (main) where

import Control.Monad (liftM)
import Control.Monad.State (State, runState, evalState, get, put)

main :: IO ()
main = do xs - readFile data
  ys - readFile data
  print (evalState readChunks xs == ys)

---

type FirstMonad = State String

readChunks :: FirstMonad String
readChunks = do xs - get
if null xs then return []
   else do let (ys, zs) = foo xs
   put zs
   rest - readChunks
   return (ys ++ rest)

---

type SecondMonad = State String

foo :: String - (String, String)
foo = runState bar

bar :: SecondMonad String
bar = do inp - get
 case inp of
 [] - return []
 x:xs - do put xs
liftM (x:) bar


module Main (main) where

import Control.Monad (liftM)
import Control.Monad.Trans (lift)
import Control.Monad.State (StateT, evalStateT, State, evalState, get, put)

main :: IO ()
main = do xs - readFile data
  ys - readFile data
  print (evalState readChunks xs == ys)

---

type InnerMonad = State String

readChunks :: InnerMonad String
readChunks = do xs - get
if null xs then return []
   else do ys - foo get put
   rest - readChunks
   return (ys ++ rest)

---

data St m = St { get_inp :: m String, put_inp :: String - m () }
type OuterMonad m = StateT (St m) m

foo :: Monad m = m String - (String - m ()) - m String
foo getter putter = evalStateT bar (St getter putter)

bar :: Monad m = OuterMonad m String
bar = do st - get
 inp - lift $ get_inp st
 case inp of
 [] - return []
 x:xs - do lift $ put_inp st xs
liftM (x:) bar

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


Re: [Haskell-cafe] Space usage problems

2006-01-10 Thread Ian Lynagh
On Tue, Jan 10, 2006 at 05:28:03PM +, Chris Kuklewicz wrote:
 I'll make a guess...
 
 Ian Lynagh wrote:
  Hi all,
  
  foo :: String - (String, String)
  foo = runState bar
  
  bar :: SecondMonad String
  bar = do inp - get
   case inp of
   [] - return []
   x:xs - do put xs
  liftM (x:) bar
 The liftM should be equivalent to
   temp - bar
   return ( (x:) temp )
 
 It looks like the first call to foo will have bar consuming the entire
 input string.

I'm not entirely sure what you mean here. The result will be the entire
input string, but State is a lazy monad, so it won't have to consume it
all before it starts returning it.

For example, if you replace the definition of foo with

foo xs = (evalState bar xs, )

then the program runs in constant space (but this isn't a solution to
the real problem, as bar will only consume a prefix of the string
there).


Thanks
Ian

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


Re: [Haskell-cafe] Space usage problems

2006-01-10 Thread Ian Lynagh
On Tue, Jan 10, 2006 at 04:44:33PM +, Ian Lynagh wrote:
 
 readChunks :: FirstMonad String
 readChunks = do xs - get
 if null xs then return []
else do let (ys, zs) = foo xs
put zs
rest - readChunks
return (ys ++ rest)

It looks like changing this let to a case fixes this example, but at the
time I'd experimented with that there must have been other issues
clouding the effect, such as the following.

Foo1 (attached) uses large amounts of memory whereas Foo2 (also
attached) runs in a little constant space. The difference is only
changing this:

else do chunk - case foo xs of
 (ys, zs) -
 do put zs
return ys
chunks - readChunks
return (chunk ++ chunks)

to this:

else case foo xs of
 (ys, zs) -
 do put zs
chunks - readChunks
return (ys ++ chunks)

but I don't have a good feeling for why this should be the case given
I'd expect chunk to be forced, and thus the case evaluated, at the same
point in Foo1 as the case is evaluated in Foo2.

Is this just a case of GHC's optimiser's behaviour depending on subtle
source changes, or am I missing something?


Thanks
Ian


module Main (main) where

import Control.Monad (liftM)
import Control.Monad.State (State, runState, evalState, get, put)

main :: IO ()
main = do xs - readFile data
  ys - readFile data
  print (evalState readChunks xs == ys)

---

type FirstMonad = State String

readChunks :: FirstMonad String
readChunks = do xs - get
if null xs then return []
   else do chunk - case foo xs of
(ys, zs) -
do put zs
   return ys
   chunks - readChunks
   return (chunk ++ chunks)

---

type SecondMonad = State String

foo :: String - (String, String)
foo = runState bar

bar :: SecondMonad String
bar = do inp - get
 case inp of
 [] - return []
 x:xs - do put xs
liftM (x:) bar


module Main (main) where

import Control.Monad (liftM)
import Control.Monad.State (State, runState, evalState, get, put)

main :: IO ()
main = do xs - readFile data
  ys - readFile data
  print (evalState readChunks xs == ys)

---

type FirstMonad = State String

readChunks :: FirstMonad String
readChunks = do xs - get
if null xs then return []
   else case foo xs of
(ys, zs) -
do put zs
   chunks - readChunks
   return (ys ++ chunks)

---

type SecondMonad = State String

foo :: String - (String, String)
foo = runState bar

bar :: SecondMonad String
bar = do inp - get
 case inp of
 [] - return []
 x:xs - do put xs
liftM (x:) bar

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


[Haskell-cafe] Re: [darcs-conflicts] how to nicely implement phantom type coersion?

2005-12-08 Thread Ian Lynagh
On Thu, Dec 08, 2005 at 09:23:22AM -0500, David Roundy wrote:
 
 data EqContext a b = EqContext { safe_coerce :: f(a,b) - f(b,a) }
 
 where f(a,b) is a function of two types that returns a type, so the value
 of f(a,b) might be (Patch a b) or (Patch x b) or something like that.
 
 But I'm not sure if this is possible in Haskell, and if it is, then it
 definitely requires some sort of tricky extension that I'm not familiar
 with...

I'm a bit confused, but if you have:

sc :: p a b - p a c
sc = unsafeCoerce#

then (with Either standing in for Patch, PatchList etc and some concrete
types as parameters to simplify things)

sc (undefined :: Either Int Char) :: Either Int Bool

is well-typed but

sc (undefined :: Either Int Char) :: Either String Char

isn't. Is that what you want?


Thanks
Ian

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


Re: [darcs-users] Re: [Haskell-cafe] fptools in darcs now available

2005-05-01 Thread Ian Lynagh
On Sun, May 01, 2005 at 08:28:15PM +0200, Sven Panne wrote:
 Gour wrote:
 
 Nice to hear you are considering to move to darcs.
 
 Basically I'm very happy with the working model of CVS, and subversion

darcs would allow you to locally record intermediate stages of a change,
making it easier to revert to the last good state if you screw up or
decide something would be better done a different way. You can also
unrecord one of the previous intermediate local commits you have made to
fix a bug or do it in a better way.

Then, when you have finished the changes and are happy with it all, you
can either send of the set of smaller changes (which might make the
history more understandable) or unrecord them all and rerecord the whole
thing (so it looks to the outside world like you just did it all at
once, as is the current case).

You can also more easily send only some of the changes you have made to
the main repo if you also have some unfinished stuff you are working on.

You can also do all this while on a plane, without bandwidth at a
conference, or whatever.


Thanks
Ian

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


Re: [Haskell-cafe] invalid character encoding

2005-03-19 Thread Ian Lynagh
On Wed, Mar 16, 2005 at 11:55:18AM +, Ross Paterson wrote:
 On Wed, Mar 16, 2005 at 03:54:19AM +, Ian Lynagh wrote:
  Do you have a list of functions which behave differently in the new
  release to how they did in the previous release?
  (I'm not interested in changes that will affect only whether something
  compiles, not how it behaves given it compiles both before and after).
 
 I got lost in the negatives here.  It affects all Haskell 98 primitives
 that do character I/O, or that exchange C strings with the C library.

In the below, it looks like there is a bug in getDirectoryContents.

Also, the error from w.hs is going to stdout, not stderr.

Most importantly, though: is there any way to remove this file without
doing something like an FFI import of unlink?

Is there anything LC_CTYPE can be set to that will act like C/POSIX but
accept 8-bit bytes as chars too?


(in the POSIX locale)
$ echo 'import Directory; main = getDirectoryContents . = print'  q.hs
$ runhugs q.hs 
[.,..,q.hs]
$ touch 1`printf \xA2`
$ runhugs q.hs
runhugs: Error occurred

ERROR - Garbage collection fails to reclaim sufficient space


$ echo 'import Directory; main = removeFile 1\xA2'  w.hs
$ runhugs w.hs

Program error: 1?: Directory.removeFile: does not exist (file does not exist)
$ strace -o strace.out runhugs w.hs  /dev/null
$ grep unlink strace.out | head -c 14 | hexdump -C
  75 6e 6c 69 6e 6b 28 22  31 3f 22 29 20 20|unlink(1?)  |
000e
$ strace -o strace2.out rm 1*
$ grep unlink strace2.out | head -c 14 | hexdump -C
  75 6e 6c 69 6e 6b 28 22  31 a2 22 29 20 20|unlink(1.)  |
000e
$ 



Now consider this e.hs:


import IO

main = do hWaitForInput stdin 1
  putStrLn Input is ready
  r - hReady stdin
  print r
  c - hGetChar stdin
  print c
  putStrLn Done!


$ { printf \xC2\xC2\xC2\xC2\xC2\xC2\xC2; sleep 30; } | runhugs e.hs
Input is ready
True

Program error: stdin: IO.hGetChar: protocol error (invalid character encoding)
$ 

It takes 30 seconds for this error to be printed. This shows two issues:
First of all, I think you should be giving an error as soon as you have
a prefix that is the start of no character. Second, hReady now only
guarantees hGetChar won't block on a binary mode handle, but I guess
there is not much we can do except document that (short of some hideous
hacks).


Thanks
Ian

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


Re: [Haskell-cafe] invalid character encoding

2005-03-19 Thread Ian Lynagh
On Sun, Mar 20, 2005 at 01:33:44AM +, [EMAIL PROTECTED] wrote:
 On Sat, Mar 19, 2005 at 07:14:25PM +, Ian Lynagh wrote:
 
  Most importantly, though: is there any way to remove this file without
  doing something like an FFI import of unlink?
  
  Is there anything LC_CTYPE can be set to that will act like C/POSIX but
  accept 8-bit bytes as chars too?
 
 en_GB.iso88591 (or indeed any .iso88591 locale) will match the old
 behaviour (and the GHC behaviour).

This works for me with en_GB.iso88591 (or en_GB), but not en_US.iso88591
(or en_US). My /etc/locale.gen contains:

en_GB ISO-8859-1
en_GB.ISO-8859-15 ISO-8859-15
en_GB.UTF-8 UTF-8

So is there anything that /always/ works?

 Indeed it's possible to have filenames (under POSIX, anyway) that H98
 programs can't touch (under Hugs).  That's pretty much follows from
 the Haskell definition FilePath = String.  The other thread under this
 subject has touched on the need for an (additional) API using an abstract
 FilePath type.

Hmm. I can't say I'm convinced by all this without having something like
that API.

 Yes, I don't see how to avoid this when using mbtowc() to do the
 conversion: it makes no distinction between a bad byte sequence and an
 incomplete one.

Perhaps you could use mbrtowc instead?

My manpage says

If the n bytes starting at s do not contain a complete multibyte  char-
acter,  mbrtowc  returns  (size_t)(-2).  This  can  happen even if n =
MB_CUR_MAX, if the multibyte string contains redundant shift sequences.

If  the  multibyte  string  starting at s contains an invalid multibyte
sequence  before  the  next   complete   character,   mbrtowc   returns
(size_t)(-1) and sets errno to EILSEQ. In this case, the effects on *ps
are undefined.

For both functions my manpage says

CONFORMING TO
   ISO/ANSI C, UNIX98


Thanks
Ian

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


Re: [Haskell-cafe] invalid character encoding

2005-03-17 Thread Ian Lynagh
On Thu, Mar 17, 2005 at 06:22:25AM +, Ian Lynagh wrote:
 
 [in brief: hugs' (hPutStr h) now behaves differently to
  (mapM_ (hPutChar h)), and ghc writes the empty string for both when
  told to write \128]

Ah, Malcolm's commit messages have just reminded me of the finaliser
changes requiring hflushes in new ghc, so it's just the hugs output that
confuses me now.


Thanks
Ian

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


Re: [Haskell-cafe] invalid character encoding

2005-03-16 Thread Ian Lynagh
On Tue, Mar 15, 2005 at 10:44:28AM +, Ross Paterson wrote:
 
 You can select binary I/O using the openBinaryFile and hSetBinaryMode
 functions from System.IO.  After that, the Chars you get from that Handle
 are actually bytes.

What about the ones sent to it?
Are all the following results intentional?
Am I doing something stupid?

[in brief: hugs' (hPutStr h) now behaves differently to
 (mapM_ (hPutChar h)), and ghc writes the empty string for both when
 told to write \128]

Running the following with new ghc 6.4 and hugs 20050308 or 20050317:

echo 'import System.IO; import System.Environment; main = do [o] - getArgs; ho 
- openBinaryFile o WriteMode; hPutStr ho \128'  run1.hs
echo 'import System.IO; import System.Environment; main = do [o] - getArgs; ho 
- openBinaryFile o WriteMode; mapM_ (hPutChar ho) \128'  run2.hs
runhugs run1.hs hugs1
runhugs run2.hs hugs2
runghc run1.hs ghc1
runghc run2.hs ghc2
ls -l hugs1 hugs2 ghc1 ghc2
for f in hugs1 hugs2 ghc1 ghc2; do echo $f; hexdump -C $f; done

gives:

-rw-r--r--  1 igloo igloo 0 Mar 17 06:15 ghc1
-rw-r--r--  1 igloo igloo 0 Mar 17 06:15 ghc2
-rw-r--r--  1 igloo igloo 1 Mar 17 06:15 hugs1
-rw-r--r--  1 igloo igloo 1 Mar 17 06:15 hugs2
hugs1
  3f|?|
0001
hugs2
  80|.|
0001
ghc1
ghc2

With ghc 6.2.2 and hugs November 2003 I get:

-rw-r--r--  1 igloo igloo 1 Mar 17 06:16 ghc1
-rw-r--r--  1 igloo igloo 1 Mar 17 06:16 ghc2
-rw-r--r--  1 igloo igloo 1 Mar 17 06:16 hugs1
-rw-r--r--  1 igloo igloo 1 Mar 17 06:16 hugs2
hugs1
  80|.|
0001
hugs2
  80|.|
0001
ghc1
  80|.|
0001
ghc2
  80|.|
0001


Incidentally, make check in CVS hugs said:

cd tests  sh testScript | egrep -v '^--( |-)'
./../src/hugs +q -w -pHugs: static/mod154.hs  /dev/null
expected stdout not matched by reality
*** static/Loaded.outputFri Jul 19 22:41:51 2002
--- /tmp/runtest11949.3 Thu Mar 17 05:46:05 2005
***
*** 1,2 
! Type :? for help
  Hugs:[Leaving Hugs]
--- 1,3 
! ERROR static/mod154.hs - Conflicting exports of entity sort
! *** Could refer to Data.List.sort or M.sort
  Hugs:[Leaving Hugs]


Thanks
Ian

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


Re: [Haskell-cafe] invalid character encoding

2005-03-15 Thread Ian Lynagh
On Tue, Mar 15, 2005 at 10:44:28AM +, Ross Paterson wrote:
 On Mon, Mar 14, 2005 at 07:38:09PM -0600, John Goerzen wrote:
  I've got some gzip (and Ian Lynagh's Inflate) code that breaks under
  the new hugs with:
  
   handle: IO.getContents: protocol error (invalid character encoding)
  
  What is going on, and how can I fix it?
 
 A Haskell 98 Handle is a character stream, and doesn't support binary
 I/O.  This would have bitten you sooner or later on systems that do CRLF
 conversion, but Hugs is now much stricter, because character streams now
 use the encoding determined by the current locale (for the C locale, that
 means ASCII only).

Do you have a list of functions which behave differently in the new
release to how they did in the previous release?
(I'm not interested in changes that will affect only whether something
compiles, not how it behaves given it compiles both before and after).

Simons, Malcolm, are there any such functions in the new ghc/nhc98?

Also, are you all agreed that the hugs interpretation of the report is
correct, and thus ghc at least is buggy in this respect? (I'm afraid I
haven't been able to test nhc98 yet).

Finally, the hugs behaviour seems a little odd to me. The below shows 4
cases where iconv complains when asked to convert utf8 to utf8, but hugs
only gives an error in one of them. In the others it just truncates the
input. Is this really correct? It also seems to behave the same for me
regardless of whether I export LC_CTYPE to en_GB.UTF-8 or C.


Thanks
Ian


printf \x00\x7F  inp1
printf \x00\x80  inp2
printf \x00\xC4  inp3
printf \xFF\xFF  inp4
printf \xb1\x41\x00\x03\x65\x6d\x70\x74\x79\x00\x03\x00\x00\x00\x00\x00  inp5
echo 'main = do xs - getContents; print xs'  run.hs
for i in `seq 1 5`; do runhugs run.hs  inp$i; done
for i in `seq 1 5`; do runghc6 run.hs  inp$i; done
for i in `seq 1 5`; do echo $i; iconv -f utf8 -t utf8  inp$i; done

which gives me the following output:

$ for i in `seq 1 5`; do runhugs run.hs  inp$i; done
\NUL\DEL
\NUL
\NUL


Program error: stdin: IO.getContents: protocol error (invalid character 
encoding)
$ for i in `seq 1 5`; do runghc6 run.hs  inp$i; done
\NUL\DEL
\NUL\128
\NUL\196
\255\255
\177A\NUL\ETXempty\NUL\ETX\NUL\NUL\NUL\NUL\NUL
$ for i in `seq 1 5`; do echo $i; iconv -f utf8 -t utf8  inp$i; done
1
2
iconv: illegal input sequence at position 1
3
iconv: incomplete character or shift sequence at end of buffer
4
iconv: illegal input sequence at position 0
5
iconv: illegal input sequence at position 0
$ 


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


Re: [Haskell-cafe] Sound library?

2004-12-04 Thread Ian Lynagh
On Fri, Dec 03, 2004 at 10:56:24AM -0500, Jason Bailey wrote:
 
 Would anyone know of packages out there for Haskell that support mp3's 
 or ogg files?

I have a (partial, I think) binding for gstreamer:

http://urchin.earth.li/~ian/minstrel/

(you only need GHC 6.3 for hcurses, hgstreamer and dependencies should
compile fun without it I believe).

I also have a complete, although error-checking-free, libalsaplayer
binding, but I found it a less pleasant API (which is why I switched):

darcs get http://urchin.earth.li/darcs/ian/halsaplayer


Thanks
Ian

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


Re: new debian packages and archive: haskell experimental

2003-07-16 Thread Ian Lynagh
On Tue, Jul 15, 2003 at 09:28:32PM -0400, Abraham Egnor wrote:
 What's the difference between the ghc6 packages provided by your archive
 and the ones currently in Debian unstable?

You can't install the unstable packages on a stable system (too old a
libc6 for one thing). These packages are just recompiled for stable,
they aren't functionally different.


Thanks
Ian

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


gconsym

2001-09-24 Thread Ian Lynagh


Just to make sure I am interpreting the report correctly, is : meant
to be a valid qconop regardless of the precedence-level and
associativity of the qconop?


Thanks
Ian


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



Re: gconsym

2001-09-24 Thread Ian Lynagh

On Mon, Sep 24, 2001 at 07:41:42AM -0700, Simon Peyton-Jones wrote:
 | Just to make sure I am interpreting the report correctly, is 
 | : meant to be a valid qconop regardless of the 
 | precedence-level and associativity of the qconop?
 
 I don't really understand the regardless of.. part.  But, yes, 
 : is a qconop, with precedence and associativity infixr 5.

Ah, I was reading it wrongly then.

Can I suggest it (the abstract syntax) is rewritten in the revised
report along a similar line to how - is handled in expressions? In fact,
I think making explicit all the things which can take a precedence or
associativity would be useful.


Thanks
Ian


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



Re: let/where

2001-09-19 Thread Ian Lynagh

On Wed, Sep 19, 2001 at 01:53:22PM -0400, Mark Carroll wrote:
 
 main = let maybe_index = maybe_read word 
in putStr (show (if maybe_index == Nothing then DP_Unknown else DP_Number 
index) ++ \n)
   where (Just index) = maybe_index
 
 BTW, is the above a sane way of getting the 'index' 'out of' the Just?
 I often seem to be using a where (Just foo) = bar type of idiom.

I'd probably write this as something like

main = case maybe_read word of
   Just index - putStrLn $ show $ if maybe_index == Nothing
   then DP_Unknown
   else DP_Number index
   Nothing - error No index found

As for let versus where, I use whatever I think looks best, which tends
to be where unless I have lots of nested ifs and cases.


Ian


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



Various software and a question

2001-02-01 Thread Ian Lynagh



Hi all

First a brief question - is there a nicer way to do something like

#ifdef __GLASGOW_HASKELL__
#include "GHCCode.hs"
#else

 import HugsCode

#endif

than that (i.e. code that needs to be different depending on if you are
using GHC or HUGS)?


Secondly, I don't know if this sort of thing is of interest to anyone,
but inspired by the number of people who looked at the MD5 stuff I
thought I might as well mention it. I've put all the Haskell stuff I've
written at http://c93.keble.ox.ac.uk/~ian/haskell/ (although I'm new
at this game so it may not be the best code in the world).

At the moment this consists of a (very nearly complete) clone of GNU ls,
and MD5 module and test program and the smae for SHA1 and DES. The ls
clone needs a ptch to GHC for things like isLink (incidentally, would
it be sensible to try and get this included with GHC? It is basically a
simple set of changes to the PosixFiles module, but needs __USE_BSD
defined (which I guess is the reason it is not in there, but it could
have it's own file?)).


Have fun
Ian, wondering how this message got to be so long


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



<    1   2