Re: [Haskell-cafe] Markdown extension for Haddock as a GSoC project

2013-04-27 Thread Alistair Bayley
How's about Creole?
http://wikicreole.org/

Found it via this:
http://www.wilfred.me.uk/blog/2012/07/30/why-markdown-is-not-my-favourite-language/

If you go with Markdown, I vote for one of the Pandoc implementations,
probably Pandoc (strict):
http://johnmacfarlane.net/babelmark2/

(at least then we're not creating yet another standard...)

Alistair



On 24 April 2013 07:23, Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Greetings,

 In light of fairly recent discussion, on this mailing list, I decided
 to investigate the topic of Markdown support for Haddock. The archives
 of the recent discussion can be seen at [1]. This post aims to
 summarise the current state of discussion. I do aim to file a proposal
 for a GSoC project on this issue but it'd be foolish to file a
 proposal for a project aiming to benefit the community without
 consulting the community itself.

 Here are some main points and ideas gathered:
 * reSt seems to have a small following - quite a bit smaller than the
 Markdown community. In fact, there seems to be a significant amount of
 people pushing for Markdown which contrasts what we can read in a
 topic from 2008 at [2]. I guess it just shows how much Markdown has
 gained in popularity in recent years.
 * There are issues with using Markdown even before we attempt to use
 it for Haskell documentation:
   * There exists no formal specification or semantics. It would seem
 that a significant number of Markdown parsers are creating by reverse
 engineering an already existing parser. This is bad because we end up
 propagating the bugs and workarounds around ambiguity that the
 original parser has.
   * As a follow-up to the previous point, the (vanilla) Markdown is
 ambiguous and there is nothing to resolve it. As Richard A. O'Keefe
 pointed out, there exist situations where it's not possible to infer
 the semantics of Markdown from its official implementation and the
 result is parser/writer-specific [6].
 * John MacFarlane has already written a Markdown parser in Haskell. It
 can be read at [3]. This means that the new extension would not need
 to rely on Pandoc. He says ``I have an experimental thing here that
 could be used as a basis (it's 7x faster than pandoc and uses 1/5 the
 memory, BSD licensed)''. This is great! The post can be seen in full
 at [4].
 * An alternative idea was to simply write a writer module for Pandoc
 for Haddock.
   * A reader module is already present.
   * According to John MacFarlane, Haddock is not expressive enough to
 take advantage of this. Furthermore, Pandoc doesn't have some
 constructions that Haddock does [4].
   * Comes back to the problem on relying on such a large package as
 Pandoc.
 * Yet another proposal was rather than introducing Markdown to
 concentrate on fixing current issues and adding features to Haddock as
 it stands [8]. This is one of the options listed at the short blog
 post at [14] by Johan Tibell.
   * David Waern, one of Haddock maintainers admits that Haddock lacks
 active development and it has been that way for a longer time. Having
 said that, he seems to believe that Markdown integration is a project
 that can realistically be completed over summer. Such project would be
 able to use the existing HTML backend in Haddock. [9].
 * Math expressions were requested and MathJAX was suggested as a
 solution at [5]. math.stackexchange.com uses MathJAX and it works
 quite well. Personally, I believe that Haskell documentation would
 benefit from this simply due to the academic nature of the language.
 * Support for Literate Haskell would be a welcome addition as
 suggested by Andrew Butterfield at [7].
 * There are issues with CPP and LHS in regards to using Markdown in
 documentation. They are pointed out at [10] by John MacFarlane and
 others that he's replying to.
 * As pointed out 5 years ago at [11], we'd have to do some
 preprocessing on current, fairly critical sections of comments used by
 Haddock. I believe these are fairly useful and it would be a shame to
 see them go.


 I hope I haven't missed anything of high importance in a list above.
 When researching the topic, issues with Markdown quickly become
 apparent. Today, there are tens of different Markdown flavours: each
 company has different needs and each company interprets the vague
 original documentation in a way that's convenient to them. In these
 situations, topics, e-mails and blog posts like this one happen. There
 is a call to action from October 2012 at [12] but there seems to be
 absolutely no progress on any of the miraculous things mentioned in
 the post. As a result of that post, a W3C community was formed at
 [13]. It's clear that the community is inactive and no progress
 towards a solution was made.

 Having considered all information gathered here, I believe this would
 make a good GSoC project. There has been interest in this for Haskell
 since 2008 judging by the size of the last thread, 

Re: [Haskell-cafe] Split and substitution using regex-pcre

2013-02-28 Thread Alistair Bayley
You cannot bend the split package to your needs?
http://hackage.haskell.org/packages/archive/split/0.2.1.2/doc/html/Data-List-Split.html

Some combination of splitWhen and a pcre-based predicate?


On 24 February 2013 22:44, Simon Marechal si...@banquise.net wrote:

 I could not find the perl-equivalents of these functions on Hackage, so
 I quickly wrote mine. Code is there:

 https://github.com/bartavelle/pcre-utils

 It should behave like perl (not really tested actually), and do strange
 things like :

  splitCompile a b
 Right [b]
  splitCompile a baaa
 Right [b]

 This will go on Hackage as I need it for the language-puppet package,
 but I am interested in comments, especially concerning the namespaces:
 * is the name of this package OK ?
 * is the name of the package OK ?
 * should I work with the regex-pcre maintainer to try to merge it ?


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

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


Re: [Haskell-cafe] ANNOUNCE: Sylvia, a lambda calculus visualizer

2012-10-01 Thread Alistair Bayley
On 2 October 2012 15:23, Conrad Parker con...@metadecks.org wrote:

 I'd love to see a game which incrementally teaches reduction and
 expansion steps in the way that DragonBox [http://dragonboxapp.com/]
 teaches algebra. That would be a learning mode like Angry Birds, where
 new combinator birds are introduced every few levels and a small
 selection of useful birds are provided to help solve each level.

 (Lambda calculus really should be a kids' game, grown-ups always make
 it seem more complex than it is).

Not sure if it's what you're after, but I was reminded of this (models
untyped lambda calculus):
  http://worrydream.com/AlligatorEggs/

Alistair

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


Re: [Haskell-cafe] Does anyone maintain trac.haskell.org?

2011-12-08 Thread Alistair Bayley
On 9 December 2011 10:39, Justin Bailey jgbai...@gmail.com wrote:
 The community Trac hosting server isn't sending email, which Trac requires.

 I've submitted several tickets to supp...@community.haskell.org but
 gotten no response.

 Does anyone maintain that server anymore?

Had the same problem in July. Raised a ticket etc. I don't think there
is anyone actually responsible for the trac server.

Alistair

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


Re: [Haskell-cafe] blog software in Haskell?

2011-10-31 Thread Alistair Bayley
On 31 October 2011 22:14, Ketil Malde ke...@malde.org wrote:

 I just upgraded my server, and set up everything again.  Except
 wordpress, as 1) I'm not too fond of its user interface, and 2) it's a
 big pile of PHP, difficult to keep updated, and basically a disaster
 waiting to happen (and in fact, it was hacked at one point).

 Before I enable it again, is there any alternatives I should consider?
 Preferably written in Haskell, of course, but other suggestions welcome
 as well.

http://gitit.net/
...has git and darcs storage.

http://www.haskell.org/haskellwiki/Web/Content_Management

There is also orchid:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/orchid-0.0.6
https://github.com/sebastiaanvisser/orchid
https://github.com/sebastiaanvisser/orchid-doc

which I recall was quite pretty, but I cannot find an online demo.

Alistair

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


Re: [Haskell-cafe] Real CMS Application in Haskell

2011-09-04 Thread Alistair Bayley
On 4 September 2011 17:46, Haisheng Wu fre...@gmail.com wrote:
 Hello guys,
   I googled for a real open source CMS application in Haskell but have no
 luck.
   So I'm wondering if Haskell is used very little in Web development area.
 Thanks.
 -Simon

There was this, quite some time ago:
  http://article.gmane.org/gmane.comp.lang.haskell.cafe/21159

However, looking at the site now I thing it's been replaced by
something more popular. Perhaps there's an interesting story behind
that...

Alistair

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


Re: [Haskell-cafe] Network.CGI and SQL Queries

2011-07-20 Thread Alistair Bayley
 There's an odd error every time I try to run this code:


 sqlReaderIO = do
     handle - connectSqlite3 table2.db
     scoresSql - quickQuery' handle SELECT * FROM pachinkoScores ORDER BY
 score, name []
     let scores = map (map (\x - fromSql x :: String)) scoresSql
     return (show scores)

 ...

 cgiTMain = do ...
   scoresPassed - sqlReaderIO
   output . renderHtml $ (inputForm n ss) maybe (inputForm n ss)
 (\mT - page Loading... (visual t v a mT ss) n v a (t + 1) mT) maxT


 When I remove the scoresPassed - sqlReaderIO line, the code run smoothly.
 Nothing else references scoresPassed. The ghc, however, gives me this
 error when the line is included:

 tankwSql.hs:144:15:
     No instance for (MonadCGI IO)
   arising from a use of `output'
     Possible fix: add an instance declaration for (MonadCGI IO)
     In the first argument of `(.)', namely `output'
     In the expression: output . renderHtml
     In the expression: output . renderHtml $ inputForm n

 tankwSql.hs:147:30:
     Couldn't match expected type `CGIT m0 CGIResult'
     with actual type `IO CGIResult'
     In the first argument of `handleErrors', namely `cgiTMain'
     In the second argument of `($)', namely `handleErrors cgiTMain'
     In the expression: runCGI $ handleErrors cgiTMain

You probably need to lift the sqlReaderIO action from IO into CGIT.
liftIO should do it.

You should consider adding type sigs to cgiTMain and sqlReaderIO, so
it's clear which monad you're in for each function.

Alistair

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


Re: [Haskell-cafe] External system connections

2011-07-11 Thread Alistair Bayley
 12 July 2011 05:49, Michael Snoyman mich...@snoyman.com wrote:

 As for Bryan's resource-pool: currently I would strongly recommend
 *against* using it for any purpose. It is based on
 MonadCatchIO-transformers[2], which is a subtly broken package. In
 particular, when I tried using it for pool/persistent in the first
 place, I ended up with double-free bugs from SQLite.

Do you have a reference explaining this brokenness? e.g. a mailing
list message? I wasn't aware of this. Are the other MonadCatchIO-*
packages also broken?

Alistair

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


Re: [Haskell-cafe] Oracle Sessions in Takusen

2011-06-02 Thread Alistair Bayley
On 3 June 2011 05:35, Kevin Quick qu...@sparq.org wrote:
 Dmitry,

 I'm not directly familiar with Takusen or its use with OracleDB, but I would
 hazard a guess that the withSession is doing FFI resource management and
 that resources obtained inside the withSession environment are no longer
 valid outside of the withSession.

 If this is the case then I would expect the following to work:

   replicateM 2 (do
        withSession (connect x x x) (do
              res - doQuery ...
              liftIO $ print res
            )
        )

 If this really is the case then it seems that withSession shouldn't be
 exporting FFI-based resources.

 -KQ

You're right, withSession shouldn't be exporting FFI obtained
resources, and I don't think it does. There are some known issues with
the Oracle code, where it allows buffers to fall out of reference (and
thus be gc'd) before the C libs have finished with them, thereby
causing segfaults. The known problems are around bind variable
buffers, so this looks like a new issue.

At least we're collecting a nice corpus of programs that cause the
Oracle backend to fail :-) I'd love to have more time to work on it...

If you don't need the Oracle-specific functionality, for now I suggest
using the ODBC driver as a substitute, as this seems to be (more)
reliable.

Alistair

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


Re: [Haskell-cafe] Encoding-aware System.Directory functions

2011-03-30 Thread Alistair Bayley
On 30 March 2011 20:53, Max Bolingbroke batterseapo...@hotmail.com wrote:

 On 30 March 2011 07:52, Michael Snoyman mich...@snoyman.com wrote:
  I could
  manually do something like (utf8Decode . S8.pack), but that presumes
  that the character encoding on the system in question is UTF8. So two
  questions:

 Funnily enough I have been thinking about this quite hard recently,
 and the situation is kind of a mess and short of implementing PEP383
 (http://www.python.org/dev/peps/pep-0383/) in GHC I can't see how to
 make it easier on the programmer. As Jason points out the best you can
 really do is probably:

  1. Treat Strings that represent filenames as raw byte sequences, even
 though they claim to be strings

  2. When presenting such Strings to the user, re-decode them by using
 the current locale encoding (which will typically be UTF-8). You
 probably want to have some means of avoiding decoding errors here too
 -- ignoring or replacing undecodable bytes -- but presently this is
 not so straightforward. If you happen to be on a system with GNU Iconv
 you can use it's C//TRANSLIT//IGNORE encoding to achieve this,
 however.



http://www.haskell.org/pipermail/libraries/2009-August/012493.html

I took from this discussion that FilePath really should be a pair of the
actual filename ByteString, and the printable String (decoded from the
ByteString, with encoding specified by the user's locale). The conversion
from ByteString to String (and vice versa) is not guaranteed to be lossless,
so you need to remember both.

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


Re: [Haskell-cafe] [Haskell] Problems with (projects|community).haskell.org

2011-02-14 Thread Alistair Bayley
On 10 February 2011 22:03, Dominique Devriese
dominique.devri...@cs.kuleuven.be wrote:
 Also, is there any news yet on a procedure for community members with
 accounts on projects.haskell.org to get access to them again? My ssh
 publickey login is no longer being accepted. I had an account mainly
 for hosting the darcs repo and the website for my project
 grammar-combinators. The website has been down for a couple of weeks
 now.

 Dominique

 P.S.: This is not a complaint, I'm just hoping for a status update.
 P.P.S.: Thanks to the people working on fixing this..

Any update on this?

Alistair

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


Re: [Haskell-cafe] Anyone here from New Zealand?

2010-08-01 Thread Alistair Bayley
On 24 July 2010 09:58, Hamish Mackenzie
hamish.k.macken...@googlemail.com wrote:
 On 24 Jul 2010, at 02:15, Tim Matthews wrote:

 Any of the haskellers here from NZ?

 I am in Wellington, Stephen is near Palmerston North. There are a few others
 elsewhere I think.

I'm currently moving from the UK back to Wellington (well,
Paraparaumu, but looking for work in Wgtn), so maybe will try to get
in touch when we're there. Won't actually be there until September.

There is this page, which has not been promoted in a while, I think:
  http://www.haskell.org/haskellwiki/Haskell_user_locations

(Frappr seems to be dead, now.)

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


Re: [Haskell-cafe] ANNOUNCE: Takusen 0.8.6

2010-08-01 Thread Alistair Bayley
At the risk of seeming a bit defensive, I'll respond to some of these points...

 Despite this, it seems to have a couple faults:
  * Few tutorials, aside from the Haddocks in Database.Enumerator

True. I put a bit of effort in to writing the docs in
Database.Enumerator as a sort of tutorial, but it doesn't work as well
as a properly written tutorial. Perhaps this would be better placed on
the wiki, but it's quite a bit of work, assuming you would prefer
something more than a simple cut-n-paste from the generated docs.


  * Very crufty old code in some spots (I see lots of references to
 GHC 6.6 and the 'extensible exceptions' changes in the cabal file
 among other places, which I believe we're all well beyond now. There
 also seems to be random tidbits that could be removed in favor of a
 library/removed because they're not necessary.) This should IMO all be
 removed under the argument Get a more recent GHC although people may
 disagree here.

Maybe... We've put some effort into supporting older versions of ghc,
mainly because quite a few distributions have quite long update
cycles. If you're stuck in an environment (some unis, some employers?)
where you are only allowed tools from the last stable distribution,
you may well be many releases behind current ghc. If everyone agrees
that 6.8 should be the oldest ghc we should test and support, then
that does make things a little simpler. Are there any distros still
shipping with ghc-6.6?

BTW, I thought extensible-exceptions first shipped with 6.10. I don't
think everyone is off 6.8 yet, so we'd want to keep that cabal switch
in for a little longer if we intend to support 6.8.


  * It would be nice if we could make it depend on nicer libraries
 instead of rolling its own stuff - for example, we have Lato's
 excellent iteratee package, and Bas van Dijk has written a (IMO
 woefully underappreciated!) 'regions' package with encapsulate the
 lightweight monadic regions idea Oleg proposed. Of course, due to
 design, neither of these may work properly for Takusen's case, and if
 they did they would very likely facilitate API changes, but it's
 something I've been thinking about in the name of making the library
 smaller and more lightweight.

iteratee and regions were both released well after Takusen was
written. I think iteratee is just the same idea generalised to other
types (Binary, ByteStrings, IO, etc). Perhaps it would help to use it
and standardise the interface, but I haven't looked into it at all. It
looks like it might be a considerable amount of work.

Using regions might be more feasible (i.e. easier), but again I
haven't considered it. Takusen's implementation also pre-dates regions
considerably, and it works well for us as is. The actual
implementation is very little code.

That is, in both cases I don't see a big benefit from switching over
to these libraries, considering the amount of work I think it would
take (esp for iteratee). There are plenty of other things on the to-do
list which I think should take higher priority e.g.
 - splitting Takusen into multiple packages: a core interface, and
then separate packages for each backend.
 - better docs, as you've requested.
 - support for blobs/clobs

As Gregory just pointed out, using other libs adds further
dependencies to Takusen. One of our earlier goals was to make it easy
to install, which in the days before cabal meant fewer dependencies on
external libs. cabal now mitigates that concern considerably, so
perhaps we should relax more now when it comes to using external libs.
Here is the list of things that I can think of right now which are
currently internalised in Takusen, but which are also implementated in
hackage libs:
 - extensible exceptions
 - EMonadIO
 - regions
 - iteratee

I'm not saying the way it is now is right or best, but it got there
through various historical decisions, which were made with the best
information available at the time, and in environments that differ
from the current.

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


[Haskell-cafe] gtk2hs and ghc-6.10.4 on Windows (Vista)

2010-02-24 Thread Alistair Bayley
On 16 February 2010 17:57, Neil Mitchell ndmitch...@gmail.com wrote:
 Hi Serguey,

 A GHC 6.10.4 version of Gtk2hs:

 http://www.mail-archive.com/gtk2hs-de...@lists.sourceforge.net/msg00340.html

 I used to recommend Gtk2hs over wxHaskell for GUI development as there
 was always a version that worked on Windows with the latest GHC
 release. I think I might have to switch back to recommending C# for
 GUI development...

Is there a trick to getting this installed? I have run the installer
in a Vista machine, both as user and admin, and the installation is
mostly successful, except that the packages are not registered with
ghc-6.10.4. Also, the first step of the install complains that GHC
does not appear to be installed correctly, try reinstalling GHC
version 6.10.4. Setup found what appears to be a non-working
installation of GHC in ...  What test does it apply to determine if
GHC is working or not?

It can run the gtk-demo, so it's not all bad, but I can't build
anything that uses it (like Yi).

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


[Haskell-cafe] Haskell IDEs on Windows; gtk2hs

2010-02-12 Thread Alistair Bayley
I thought I'd try some of the Haskell IDEs: eclipsefp, leksah, and yi.
So far, leksah requires gtk2hs (and apparently yi can use it too?),
and the latest gtk2hs installer for Windows doesn't like the latest
Haskell Platform, so I'm going to try building gtk2hs from source,
unless anyone tells me that it's a waste of time.

Building yi fails with:

Yi\Prelude.hs:182:9:
Duplicate instance declarations:
  instance Category Accessor.T -- Defined at Yi\Prelude.hs:182:9-38
  instance Category Accessor.T
-- Defined in data-accessor-0.2.1.2:Data.Accessor.Private
cabal: Error: some packages failed to install:
yi-0.6.1 failed during the building phase. The exception was:
exit: ExitFailure 1

Presumably data-accessor has been updated, but yi has not? What is the
easiest fix? Downgrade to an earlier version of data-accessor?

So that just leaves eclipsefp. Still trying to figure out how to
install eclipse plugins...

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


Re: [Haskell-cafe] programmatic DB interface?

2010-02-04 Thread Alistair Bayley
 What is currently the recommended
 higher level data base interface for Haskell?

 I want to construct queries in a programmatic/algebraic way,

 Would takusen help? Where's its home page?
 this does not work: http://darcs.haskell.org/takusen/

Takusen still requires you to supply queries as strings, so no, it
wouldn't help. BTW, it has moved to http://code.haskell.org/takusen

The only game in town is HaskellDB, AFAIK.

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


Re: [Haskell-cafe] Haskell Platform

2010-01-21 Thread Alistair Bayley
 How are the efforts on Haskell Platform for GHC 6.12.1 going?

 I'm considering joining those brave heroes. Where can I apply?

Joining the mailing list would be a good place to start:
  http://projects.haskell.org/cgi-bin/mailman/listinfo/haskell-platform

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


Re: [Haskell-cafe] Takusen - reading from one db inserting into another

2010-01-18 Thread Alistair Bayley
Hello Günther,

 I know how to use Takusen with a *single* connection, but I cannot figure
 out how to read from one database while inserting to another.

At present it's not possible. The lats time you asked about it, Oleg
and I tried a design where the DBM monad becomes a DBMT monad
transformer. This permits multiple connections, but the resulting
user-land code didn't work as well as I wanted. If you like I can try
to tidy it up and send you the darcs patch.

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


[Haskell-cafe] ssh ports for monk and nun?

2010-01-12 Thread Alistair Bayley
Trying to get ssh working via putty from behind my company firewall.
Had some success in the past with sourceforge because they had ssh
daemons listening on ports 80 and 443, to aid prisoners like myself.
Does anyone know if the monk (darcs.haskell.org) and nun
(code.haskell.org) servers accept ssh on ports other than 22?

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


Re: [Haskell-cafe] ssh ports for monk and nun?

2010-01-12 Thread Alistair Bayley
2010/1/12 Jason Dusek jason.du...@gmail.com:
  Monk and nun?

The haskell.org code/project/... servers:
  http://www.haskell.org/haskellwiki/Haskell.org_domain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: ssh ports for monk and nun?

2010-01-12 Thread Alistair Bayley
 Trying to get ssh working via putty from behind my company firewall.
 Had some success in the past with sourceforge because they had ssh
 daemons listening on ports 80 and 443, to aid prisoners like myself.
 Does anyone know if the monk (darcs.haskell.org) and nun
 (code.haskell.org) servers accept ssh on ports other than 22?

I should also have said: I'm open to suggestions and advice on using
darcs+cabal+ssh with restrictive firewalls and http proxies. I
currently have cntlm (an authenticating proxy server) installed, so I
can use cabal (and darcs get will work with this too), but I want to
be able to push patches too.

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


Re: [Haskell-cafe] Relational Algebra

2009-10-15 Thread Alistair Bayley
 has anybody already developed an EDSL for relational algebra?

 HaskellDB does that, but its current implementation only allows for
 generating SQL, are there other implementations?

Hello Günther,

Ganesh did something called squiggle a while ago:
http://code.haskell.org/squiggle/unstable/

I've done something similar but it's not published or hosted anywhere,
so no link. Can upload it to code.haskell.org if you're interested.

Both of our projects just generate SQL though, AFAIK. Was there
something else you wanted to generate?

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


Re: [Haskell-cafe] Takusen: *** Exception: readUTF8Char: illegal UTF-8 character 252

2009-09-08 Thread Alistair Bayley
Hello Günther,

It looks like Access is not using UTF8 as its text encoding. I have
Access at work, so I can look into this at some point.

The ODBC code assumes the encoding is always UTF8. For some drivers
(e.g. PostgreSQL) you must configure the ODBC driver correctly to
provide UTF8.

Does Takusen work with Access for US7ASCII text? If not, this would
suggest that Access is using UTF16 (which is common on Windows).

Alistair

2009/9/8 Günther Schmidt gue.schm...@web.de:
 Hi all,

 I'm trying to use Takusen ODBC on Windows.

 I'm using a German WinXP Pro and try to connect to an MS Access database. As
 soon as I try to do some inserts the above mentioned exception shows up.

 Does anyone know a work around for this?

 Günther

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

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


Re: [Haskell-cafe] Takusen - is anyone currently using it on Win32 - ODBC?

2009-08-23 Thread Alistair Bayley
2009/8/23 Günther Schmidt gue.schm...@web.de:

 is anyone currently using takusen with odbc on Win32? In particular with MS
 Access?

 I'm asking because I noticed that when database libraries are declared to
 work with ODBC no one seems to mean Win32 ODBC, but rather Unix ODBC.

Yes. The ODBC backend is tested on Win32, although not with MS Access
(Oracle, PostgreSQL, and MS SQL Server have been tested).

If you have problems with MS Access, do let me know.

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


[Haskell] ANN: Takusen 0.8.4

2009-05-01 Thread Alistair Bayley
ANN: Takusen 0.8.4

This is mainly a get it working with ghc-6.10 release.

Changes since 0.8.3:

 - ODBC support: some bug fixes, and basic support for Out-parameters.
   There is at least one major outstanding bug with Out-parameters,
   where marshalling a String output bind-variable doesn't work correctly
   (if it was modified, you still get the String you passed in back,
   rather than the new String).

 - Sqlite: bug fix for resource leak: if a command (like rollback or commit)
   raised an error, the prepared-statement handle was not closed.

 - cabal: requires cabal 1.6 (or later). With ghc-6.6 on Windows you will
   need a later cabal than 1.6.0.1, as there is a bug which prevents building
   (setup configure fails with
   setup: fdGetMode: invalid argument (Invalid argument)).
   Eric Mertens patch for ODBC on OS x. Greg Leclerq patch for cabal 1.6.
   Thanks also to Austin Siepp and Brian Callendar for their patches.

 - ghc-6.10: will build with ghc's 6.10, 6.8, 6.6.
   Note that Takusen won't work with ghc-6.10.2 out-of-the-box,
   because the time package is missing. If you install time manually
   then it should be OK (but this is untested).

   We use the new extensible exceptions, but we have done so by including it
   within our own source tree. This will make it easier to use Takusen with
   older ghc's, and reduces the number of external package dependencies.

   We have dropped support for 6.4. That's not to say Takusen isn't usable
   with 6.4, just that we no longer test that configuration.


The release bundle:
  http://hackage.haskell.org/packages/archive/Takusen/0.8.4/Takusen-0.8.4.tar.gz
The latest code:
  darcs get http://darcs.haskell.org/takusen
Docs:
  http://darcs.haskell.org/takusen/doc/html/index.html

If you have cabal-install, then this command should work:
  cabal install Takusen --flags=sqlite odbc oracle postgres
... but it doesn't (at least for the version of cabal-install
that I have) because the .tar.gz file I uploaded has a bogus checksum.

A comprehensive description of API usage can be found in the documentation
for module Database.Enumerator (look for the Usage section):
  http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html

Note that the haddock docs won't build with cabal-1.6.0.2 or earlier.
This is because our literate-haskell source files need to be properly
preprocessed before being passed to haddock.
At the time of writing, you'll need the cabal HEAD to build the docs.



Future plans:

 - Output bind-parameters and multiple-result sets for ODBC

 - support for Blobs and Clobs

 - FreeTDS backend (Sybase and MS Sql Server)... maybe


For those of you unfamiliar with Takusen, here is our HCAR blurb:

Takusen is a DBMS access library. Like HSQL and HDBC, we support
arbitrary SQL statements (currently strings, extensible to anything
that can be converted to a string).

Takusen's 'unique-selling-point' is safety and efficiency.
We statically ensure all acquired database resources - such
as cursors, connection and statement handles - are released, exactly
once, at predictable times. Takusen can avoid loading the whole result
set in memory, and so can handle queries returning millions of rows in
constant space. Takusen also supports automatic marshalling and
unmarshalling of results and query parameters. These benefits come
from the design of query result processing around a left-fold
enumerator.

Currently we fully support ODBC, Oracle, Sqlite, and PostgreSQL.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell-cafe] ANN: Takusen 0.8.4

2009-05-01 Thread Alistair Bayley
ANN: Takusen 0.8.4

This is mainly a get it working with ghc-6.10 release.

Changes since 0.8.3:

 - ODBC support: some bug fixes, and basic support for Out-parameters.
   There is at least one major outstanding bug with Out-parameters,
   where marshalling a String output bind-variable doesn't work correctly
   (if it was modified, you still get the String you passed in back,
   rather than the new String).

 - Sqlite: bug fix for resource leak: if a command (like rollback or commit)
   raised an error, the prepared-statement handle was not closed.

 - cabal: requires cabal 1.6 (or later). With ghc-6.6 on Windows you will
   need a later cabal than 1.6.0.1, as there is a bug which prevents building
   (setup configure fails with
   setup: fdGetMode: invalid argument (Invalid argument)).
   Eric Mertens patch for ODBC on OS x. Greg Leclerq patch for cabal 1.6.
   Thanks also to Austin Siepp and Brian Callendar for their patches.

 - ghc-6.10: will build with ghc's 6.10, 6.8, 6.6.
   Note that Takusen won't work with ghc-6.10.2 out-of-the-box,
   because the time package is missing. If you install time manually
   then it should be OK (but this is untested).

   We use the new extensible exceptions, but we have done so by including it
   within our own source tree. This will make it easier to use Takusen with
   older ghc's, and reduces the number of external package dependencies.

   We have dropped support for 6.4. That's not to say Takusen isn't usable
   with 6.4, just that we no longer test that configuration.


The release bundle:
  http://hackage.haskell.org/packages/archive/Takusen/0.8.4/Takusen-0.8.4.tar.gz
The latest code:
  darcs get http://darcs.haskell.org/takusen
Docs:
  http://darcs.haskell.org/takusen/doc/html/index.html

If you have cabal-install, then this command should work:
  cabal install Takusen --flags=sqlite odbc oracle postgres
... but it doesn't (at least for the version of cabal-install
that I have) because the .tar.gz file I uploaded has a bogus checksum.

A comprehensive description of API usage can be found in the documentation
for module Database.Enumerator (look for the Usage section):
  http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html

Note that the haddock docs won't build with cabal-1.6.0.2 or earlier.
This is because our literate-haskell source files need to be properly
preprocessed before being passed to haddock.
At the time of writing, you'll need the cabal HEAD to build the docs.



Future plans:

 - Output bind-parameters and multiple-result sets for ODBC

 - support for Blobs and Clobs

 - FreeTDS backend (Sybase and MS Sql Server)... maybe


For those of you unfamiliar with Takusen, here is our HCAR blurb:

Takusen is a DBMS access library. Like HSQL and HDBC, we support
arbitrary SQL statements (currently strings, extensible to anything
that can be converted to a string).

Takusen's 'unique-selling-point' is safety and efficiency.
We statically ensure all acquired database resources - such
as cursors, connection and statement handles - are released, exactly
once, at predictable times. Takusen can avoid loading the whole result
set in memory, and so can handle queries returning millions of rows in
constant space. Takusen also supports automatic marshalling and
unmarshalling of results and query parameters. These benefits come
from the design of query result processing around a left-fold
enumerator.

Currently we fully support ODBC, Oracle, Sqlite, and PostgreSQL.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Takusen, postgres and boolean fields

2009-04-25 Thread Alistair Bayley
2009/4/25 Sasha Shipka xao...@gmail.com:
 When I did SELECT statement I handled boolean field as String, and
 convert it to Bool.
 However when I did update or insert, I must bind those values, then
 takusen calls foreign postgres library and function with ? and
 values of proper type. So I cannot use neither Bool neither String in
 bindP.

 Instead of binding, I've used ugly hack :
 update some_table set some_boolean_field = ? ... [bindP True, ...]
 is replaced with
 (printf update some_table set some_boolean_field = '%s' ...  t) [...]
 I really hate it and I hope there is better way to do it.

It should be pretty simple to add Bool instances to the class that
handles bind variable marshalling. I'll look into it on Monday. As a
workaround for now, can you use the CAST sql function to convert text
to bool values in Postgres?

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


Re: [Haskell-cafe] strange performance issue with takusen 0.8.3

2009-04-07 Thread Alistair Bayley
2009/4/6 Marko Schütz markoschu...@web.de:

 I have an application where some simple data extracted from some
 source files is inserted into a PostgreSQL database. The application
 uses Takusen and is compiled with GHC 6.8.3. Some (59 in the test
 data) of the selects take on average 460ms each for a total time for
 this sample run of 30s. I prepare one select statement at the
 beginning of the run into which I then bind the specific values for
 every one of the selects. It does not seem to make a difference
 whether I do this or whether I just use a new statement for every
 select.

 For comparison, I have collected the SQL statements in a file with
 PREPARE ... and DEALLOCATE for _every_ select and then run this file
 through psql. This takes 2s!

Hello Marko,

I'm finding it hard to see what the problem is here. Is it that your
query takes 460ms, and you need it to be quicker? Or is it something
else? It would help to have some example code. Can you make a test
case which reproduces te problem, that you could share?


 For comparison, I have collected the SQL statements in a file with
 PREPARE ... and DEALLOCATE for _every_ select and then run this file
 through psql. This takes 2s!

If all you are doing is preparing and deallocating - i.e. not
executing - then that will be very quick, because the queries are
never executed.

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


Re: [Haskell-cafe] ANNOUNCE: vacuum-cairo: a cairo frontend to vacuumfor live Haskell data visualization

2009-04-01 Thread Alistair Bayley
2009/3/31 Peter Verswyvelen bugf...@gmail.com:
 Maybe GHCi has a bug when it comes to DLL lookup.
 I had an application that worked fine when compiled with GHC, but failed
 with GHCi (libglew.dll not found)
 I used procmon to monitor which files the GHC* processes searched, and it
 seemed that the compiled version looked for libglew32.dll, while GHCi was
 looking for libglew.dll
 Since this only happened with our own wrapper project, I thought we made a
 mistake, but maybe you could also use procmon to figure out what GHCi is
 doing, it might be a bug.

ghci has a custom linker which behaves differently from gnu ld, which
is what ghc uses. I don't recall the exact details (if I ever knew
them), just that it differs. So something that works with ghc won't
necessarily do so with ghci.

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


Re: [Haskell-cafe] Problem using #define in .hsc files

2009-03-30 Thread Alistair Bayley
2009/3/29 Johan Tibell johan.tib...@gmail.com:

 foreign import CALLCONV unsafe send
    c_send :: CInt - Ptr a - CSize - CInt - IO CInt

 Compiling results in:

 parse error on input `CALLCONV'


This is what we use in Takusen's Database.ODBC.OdbcFunctions.hsc:

#ifdef mingw32_HOST_OS
#let CALLCONV = stdcall
#else
#let CALLCONV = ccall
#endif

foreign import #{CALLCONV} unsafe sql.h SQLAllocHandle sqlAllocHandle ::
  SqlHandleType - Handle - Ptr Handle - IO SqlReturn

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


Re: [Haskell-cafe] examples for error handling in takusen?

2009-03-16 Thread Alistair Bayley
2009/3/14 Gü?nther Schmidt gue.schm...@web.de:
 Hi,

 can someone please point me to error handling examples with takusen?

 I try to run a piece of code with takusen but just get the very sparse
 Database.InternalEnumerator.DBException

Hello Günther,

We use dynamic exceptions in Takusen, which is why you don't get much
useful information when an exception is thrown. We will include the
new extensible-exceptions code in the next release, so once that it
done perhaps we can change the way we do exceptions so that you get
better messages by default.

There are some basic exception handling functions in
Database.Enumerator which should help. Firstly, you need to add an
exception handler with catchDB. Then you can choose to ignore the
error, report it, or re-raise it (see basicDBExceptionReporter and
reportRethrow). Also, the DBException constructors are exported, so
you can pattern match on it to extract more information, like
SqlState, error number, and error message.

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


Re: [Haskell-cafe] Can this be done?

2009-02-11 Thread Alistair Bayley
2009/2/11 Cristiano Paris cristiano.pa...@gmail.com:
 I wonder whether this can be done in Haskell (see muleherd's comment):

 http://www.reddit.com/r/programming/comments/7wi7s/how_continuationbased_web_frameworks_work/

WASH did/does something similar. You can certainly write applications
in a similar, workflow-ish style (rather than like a state machine).

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


Re: Pragma not recognised when wrapped in #ifdef

2009-02-10 Thread Alistair Bayley
 {-# LANGUAGE CPP #-}
 #ifdef PRAGMA_DERIVE_TYPEABLE
 {-# LANGUAGE DeriveDataTypeable #-}
 #else
 {-# OPTIONS -fglasgow-exts #-}
 #endif
 -- This file is Test/Fail.hs.
 -- ghc --make  -optP-DPRAGMA_DERIVE_TYPEABLE -XCPP Test.Fail
 module Test.Fail where
 import Data.Generics
 data Fail = Fail deriving Typeable

 If compile this wih the command
  ghc --make  -optP-DPRAGMA_DERIVE_TYPEABLE -XCPP Test.Fail
 then I get this error from ghc-6.10.1:

 [1 of 1] Compiling Test.Fail( Test\Fail.hs, Test\Fail.o )

 Test\Fail.hs:11:26:
Can't make a derived instance of `Typeable Fail'
  (You need -XDeriveDataTypeable to derive an instance for this class)
In the data type declaration for `Fail'


No response. I'd like to know if this is a bug (that's what it looks
like to me), or just a mistake I've made.

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


Re: Pragma not recognised when wrapped in #ifdef

2009-02-10 Thread Alistair Bayley
2009/2/10 Simon Peyton-Jones simo...@microsoft.com:
 I'm guessing a bit here, but it looks as if you intend this:

 * GHC should read Foo.hs, and see {-# LANGUAGE CPP #-}
 * Then it should run cpp
 * Then it should look *again* in the result of running cpp,
  to see the now-revealed {-# LANGUAGE DeriveDataTypeable #-}

 I'm pretty sure we don't do that; that is, we get the command-line flags once 
 for all from the pre-cpp'd source code.  Simon or Ian may be able to confirm.

 If so, then this amounts to
   a) a documentation bug: it should be clear what GHC does
   b) a feature request, to somehow allow cpp to affect in-file flags
  I'm not sure what the spec would be

I see. So ghc will scan the source initially for pragmas, and add any
it finds as command-line flags. Having done that, it then proceeds
through the normal processing pipeline.

I had assumed (from the manual section 5.4.3) that the pipeline was this:
 - unlit
 - cpp
 - haskell compiler
 - c compiler (defunct?)
 - assembler
 - linker

and I also assumed that the pragmas would be parsed by the haskell
compiler i.e. post unlit and cpp. It hadn't occured to me that this
implementation would make the CPP pragma redundant... and the
implications thereof.

I'd love (b), but will settle for (a) for now. I was trying to use cpp
to switch between the DeriveDataTypeable pragma for 6.10, and
glasgow-exts for 6.8 and 6.6. I've decided to push this out to the
cabal file instead, so I guess I don't have this problem any more, but
it was a bit puzzling.

Perhaps CPP shouldn't be a pragma, just a command-line flag? It seems
to be the only one that affects/involves preprocessor(s). AFAICT, the
others all affect the haskell compiler stage.

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


[Haskell-cafe] Re: haddock-2.3.0 literate comments discarded from .lhs input

2009-02-07 Thread Alistair Bayley
2009/2/6 Duncan Coutts duncan.cou...@worc.ox.ac.uk:

 Yes, against my better judgement the code in Cabal for haddock-2.x does
 not run cpp or unliting like it does for haddock-0.x. Instead it assumes
 that haddock-2.x will do all the cpp and unliting itself. Obviously this
 mean the special unliting mode that Cabal provides is not usable with
 haddock-2.x.

 The solution is to do the pre-processing the same for haddock-0.x and
 2.x. Generally the haddock code in Cabal is a horrible inconsistent
 mess. I believe Andrea Vezzosi has been looking at rewriting it, which
 is good news.

In Distribution.Simple.Haddock, in the haddock function we have:

withLib pkg_descr () $ \lib - do
let bi = libBuildInfo lib
modules = PD.exposedModules lib ++ otherModules bi
inFiles - getLibSourceFiles lbi lib
unless isVersion2 $ mockAll bi inFiles

So I guess the easiest thing to do right now is remove the unless
isVersion2 $ . I'm testing this at the moment, so when I get it
working (or not) I'll let you know, and maybe send a patch.

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


Pragma not recognised when wrapped in #ifdef

2009-02-06 Thread Alistair Bayley
I have this little test program:

{-# LANGUAGE CPP #-}
#ifdef PRAGMA_DERIVE_TYPEABLE
{-# LANGUAGE DeriveDataTypeable #-}
#else
{-# OPTIONS -fglasgow-exts #-}
#endif
-- This file is Test/Fail.hs.
-- ghc --make  -optP-DPRAGMA_DERIVE_TYPEABLE -XCPP Test.Fail
module Test.Fail where
import Data.Generics
data Fail = Fail deriving Typeable

If compile this wih the command
  ghc --make  -optP-DPRAGMA_DERIVE_TYPEABLE -XCPP Test.Fail
then I get this error from ghc-6.10.1:

[1 of 1] Compiling Test.Fail( Test\Fail.hs, Test\Fail.o )

Test\Fail.hs:11:26:
Can't make a derived instance of `Typeable Fail'
  (You need -XDeriveDataTypeable to derive an instance for this class)
In the data type declaration for `Fail'

I've checked the preprocessor output with -E, and that looks fine. I
can compile the preprocessor output with ghc without errors.

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


[Haskell-cafe] haddock-2.3.0 literate comments discarded from .lhs input

2009-02-06 Thread Alistair Bayley
I have this test case for Haddock (2.3.0):

--

|
Module  :  Test.Haddock
Copyright   :  (c) 2009 Alistair Bayley
License :  BSD-style
Maintainer  :  alist...@abayley.org
Stability   :  stable
Portability :  portable

Test case for Haddock.


 module Test.Haddock
   (
   -- $named_block
   Fail(..)
   )
 where
 data Fail = Fail | Succeed

$named_block

This is some hadock documentation.

--

This fails with:

[1 of 1] Compiling Test.Fail( Test\Fail.hs, Test\Fail.o )

Test\Fail.hs:11:26:
Can't make a derived instance of `Typeable Fail'
  (You need -XDeriveDataTypeable to derive an instance for this class)
In the data type declaration for `Fail'

If I manually unlit, then Haddock is happy:

--

-- |
-- Module  :  Test.Haddock2
-- Copyright   :  (c) 2009 Alistair Bayley
-- License :  BSD-style
-- Maintainer  :  alist...@abayley.org
-- Stability   :  stable
-- Portability :  portable
-- 
-- Test case for Haddock.

module Test.Haddock2
  (
  -- $named_block
  Fail(..)
  )
where
data Fail = Fail | Succeed

-- $named_block
-- 
-- This is some hadock documentation.

--


so it looks as though it's discarding the literate comments. Is this
intended? I was under the impression that because it used the ghc
parser, it could now properly handle .lhs input.

Ona related note, we have a nice unlitter in cabal that would preserve
these comments before invoking haddock. Is this still used with
haddock2, or does it now assume haddock2 will do the right thing?

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


[Haskell-cafe] Re: haddock-2.3.0 literate comments discarded from .lhs input

2009-02-06 Thread Alistair Bayley
 [1 of 1] Compiling Test.Fail( Test\Fail.hs, Test\Fail.o )

 Test\Fail.hs:11:26:
Can't make a derived instance of `Typeable Fail'
  (You need -XDeriveDataTypeable to derive an instance for this class)
In the data type declaration for `Fail'

 Are you processing the above module but it is called Test.Fail in
 reality? Have you stripped out a deriving statement from the example
 above? I'm very confused by this message :)


Sorry, my mistake. I pasted the error message from a different
problem. This is the error I get from haddock:

C:\bayleya\eclipse\workspace\takusen\srchaddock -h --odir=doc Test/Haddock.lhs
Cannot find documentation for: $named_block

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


Re: [Haskell-cafe] Elegant powerful replacement for CSS

2009-02-03 Thread Alistair Bayley
2009/2/3 Peter Verswyvelen bugf...@gmail.com:
 Isn't CSS about giving a style to the views in the model-view-controller
 paradigm? So basically it is a way to change the look of a user interface,
 without having to change the user interface definition itself.

In theory CSS separates content from presentation. In reality it looks
like it isn't really powerful enough. Serendipitously, this rant
popped up on reddit recently:
http://www.flownet.com/ron/css-rant.html

Summary: CSS's failures mean that the rendering of a page depends on
the order of elements in the content.

We have CleverCSS: a little less ambitious than Conal and Jeff
imagined, I think, but still an improvement over raw CSS:
http://sandbox.pocoo.org/clevercss-hs/

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


Re: [Haskell-cafe] Takusen 0.8.3 install problems

2009-02-01 Thread Alistair Bayley
  You can probably just remove the Setup.lhs and build with defaults
  (we're doing that at galois, we use Takusen).
 
  -- Don

I'm surprised this works, unless you also change the imports of
Control.Exception to Control.OldException. The new exception module is
part of the reason it's taking me a while to port to 6.10.1. Nearly
there though; only the haddock failures to fix and then we can
release.

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


Re: [Haskell-cafe] Re: databases in Haskell type-safety

2009-01-30 Thread Alistair Bayley
2009/1/30 guenni68 red...@fedoms.com:
 Hi Alistair,

 yes, please, pretty please do!

 I really am desparate, I'm running into so much trouble because I have
 to export to MS-Access and I'm a little out of luck with HDBC. HDBC
 works like a charm
 unless you have to use MS-Access.

Hmm... it's not likely you'll have much success with Takusen either,
as you will also have to use the ODBC bindings for MS Access, and I
have not tested this combination. Perhaps you can consider an
alternative route for export, like CSV?

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


Re: [Haskell-cafe] haddock-2.3.0 error: file name does not match module name

2009-01-30 Thread Alistair Bayley
 This has been reported before:

  http://trac.haskell.org/haddock/ticket/73#comment:4

 Not sure what's going on yet. If anyone's got a minimal test-case,
 that'd be great.

This is what fails for me (in Test/Fail.hs):

{- # LANGUAGE CPP #-}
module Test.Fail

I've added this to the trac ticket. Note the space between {- and #.

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


[Haskell-cafe] haddock-2.3.0 error: file name does not match module name

2009-01-29 Thread Alistair Bayley
I'm getting an error when I run setup haddock-2.3.0 on the Takusen src:

haddock.exe: File name does not match module name:
Saw: `Main'
Expected: `Database.Enumerator'

I assume that it's procesing file Database.Enumerator.lhs when it
emits this, but I'm puzzled because the module name in
Database.Enumerator.lhs is certainly Database.Enumerator, and not
Main.

Or am I looking in the wrong place?

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


Re: [Haskell-cafe] haddock-2.3.0 error: file name does not match module name

2009-01-29 Thread Alistair Bayley
2009/1/29 Matthijs Kooijman matth...@stdin.nl:
 I assume that it's procesing file Database.Enumerator.lhs when it
 emits this, but I'm puzzled because the module name in
 Database.Enumerator.lhs is certainly Database.Enumerator, and not
 Main.
 Any chance the module statement in the file is wrong? I think I remember
 seeing this error once when I accidentally typed Module instead of module.
 Apparently ghc assumes Main when there is no valid module statement.

It's not this, but it certainly looks like something similar is
confusing haddock.

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


Re: [Haskell-cafe] Re: databases in Haskell type-safety

2009-01-29 Thread Alistair Bayley
 I recently got an email back from Alstair Bayley who is one of the
 Takusen authors, and they said they are preparing a GHC 6.10 release
 (I was *not* the only person to submit a patch for ghc 6.10 building)
 but it may take a little while. You might want to get in contact with
 Alstair and ask what the current progress is.

I've got it building (tests pass etc) but the haddock docs won't build
at present (with ghc-6.10.1). I want to get these little problems
sorted out before I package up the next release. If you're desperate
then I could push what I have so far into the repo and you could build
from that.

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


[Haskell-cafe] ANN: Takusen 0.8.3

2008-07-11 Thread Alistair Bayley
Changes since 0.8.1 (I put 0.8.2 up on hackage with an error in Setup.hs,
so it's been skipped):

 - ODBC support: datetime marshalling is improved. For bind parameters
   this uses the timestamp struct for most back-ends, but String for
   MS SQL Server because populating the timestamp struct always failed.

 - more Cabal improvements: now uses configurations, so the Setup.hs
   script should be both simpler and more robust. Requires Cabal = 1.4.
   Oracle backend on Linux should build nicely.

 - bug fix for a resource leak if an exception was thrown when initiating
   a query (the Statement handle was not closed).

 - some basic result-set validation against the iteratee: if you try to
   fetch a column that is not in the result-set, an error is thrown
   (rather than garbage returned).


The release bundle:
  http://hackage.haskell.org/packages/archive/Takusen/0.8.3/Takusen-0.8.3.tar.gz
The latest code:
  darcs get http://darcs.haskell.org/takusen
Docs:
  http://darcs.haskell.org/takusen/doc/html/index.html

A comprehensive description of API usage can be found in the documentation
for module Database.Enumerator (look for the Usage section):
  http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html


Future plans:

 - Output bind-parameters and multiple-result sets for ODBC

 - FreeTDS backend (Sybase and MS Sql Server)

 - support for Blobs and Clobs


For those of you unfamiliar with Takusen, here is our HCAR blurb:

Takusen is a DBMS access library. Like HSQL and HDBC, we support
arbitrary SQL statements (currently strings, extensible to anything
that can be converted to a string).

Takusen's 'unique-selling-point' is safety and efficiency.
We statically ensure all acquired database resources - such
as cursors, connection and statement handles - are released, exactly
once, at predictable times. Takusen can avoid loading the whole result
set in memory, and so can handle queries returning millions of rows in
constant space. Takusen also supports automatic marshalling and
unmarshalling of results and query parameters. These benefits come
from the design of query result processing around a left-fold
enumerator.

Currently we fully support ODBC, Oracle, Sqlite, and PostgreSQL.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The state of database libraries

2008-07-04 Thread Alistair Bayley
2008/7/4 Chris Eidhof [EMAIL PROTECTED]:

 I'm figuring out how to do databases in Haskell (on OS X). So far, I've tried 
 the following approaches:

 1. hdbc. I'd like to connect to MySQL, so I need the ODBC backend. I couldn't 
 get this to work under OS X, while I installed myodbc, which seems to be 
 broken.

 2. hsql. The packages on hackage don't compile, so I grabbed the darcs 
 version.

Bummer, dude.

The only database library that directly supports MySQL is HSQL. If you
want to use another library, you'll have to get the ODBC MySQL backend
working.

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


Re: Takusen build error

2008-07-01 Thread Alistair Bayley
 I get a strange error building Takusen (more precisely: the module
 Foreign/C/UTF8.hs) with ghc-6.8.3. It says

 [1 of 9] Compiling Foreign.C.UTF8   ( Foreign/C/UTF8.hs,
 dist/build/Foreign/C/UTF8.o )
 /tmp/ghc18936_0/ghc18936_0.s: Assembler messages:

 /tmp/ghc18936_0/ghc18936_0.s:1257:0:
 Error: symbol `base_GHCziBase_Z0T_closure' is already defined

 I compiled ghc-6.8.3 from source, using ghc-6.8.2 to bootstrap.


What happens when you say:
  ghc -c Foreign/C/UTF8.hs

I expect you get the same error. If so, then this is one for ghc
maintainers. If not, then we'll have to do some more digging.

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-30 Thread Alistair Bayley
 Yes... I've had a quick look at the instant client packages. The SDK
 zip just puts the headers under instantclient_10_2/sdk/include (which
 is still not $ORACLE_HOME/rdbms/public, but c'est la vie). So it looks
 like the .rpm puts them somewhere completely different:
 /usr/include/oracle/10.2.0.4/client. Do you also have
 $ORACLE_HOME/sdk/include, with headers in?

 No, in ORACLE_HOME there is only 'bin' and 'lib'.

I haven't found a way to detect where headers are installed, so I
propose that the Setup.hs assumes $ORACLE_HOME/rdbms/public (for
Unix), and you can add more with --extra-include-dirs=... . What do
you think?

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-27 Thread Alistair Bayley
2008/6/26 Henning Thielemann [EMAIL PROTECTED]:

 Do you need to say -lclntsh when you use ghc to compile?

 Ah, I see, I must run both GHCi and GHC with -package Takusen and everything
 is fine.

This still doesn't seem right. Both ghci and ghc --make should
automatically link the package. The only time you should need to use
-package is in ghc batch mode i.e. ghc sans --make.


 configOracle verbose buildtools = do
  if not (sqlplusProgram `isElem` buildtools)
   then return Nothing
   else do
 path - getEnv ORACLE_HOME
 info verbose (Using Oracle:  ++ path)
 let (libDir, includeDir) =
 if isWindows
   then (bin, oci/include)
   else (lib, /usr/include/oracle/10.2.0.4/client)
 makeConfig path libDir includeDir

 This is obviously a hack. We should get the Oracle include path from the
 user, maybe via another environment variable or a custom Cabal option.

Yes... I've had a quick look at the instant client packages. The SDK
zip just puts the headers under instantclient_10_2/sdk/include (which
is still not $ORACLE_HOME/rdbms/public, but c'est la vie). So it looks
like the .rpm puts them somewhere completely different:
/usr/include/oracle/10.2.0.4/client. Do you also have
$ORACLE_HOME/sdk/include, with headers in?

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-26 Thread Alistair Bayley
 Now I can start GHCi with the example program you gave me. However I have to
 start with -lclntsh, otherwise symbol OCIEnvCreate cannot by found.
 I thought I do not need this option, because the installed Takusen package
 contains the library name:

 $ grep clntsh dist/installed-pkg-config
 extra-libraries: clntsh clntsh

 I wonder why it appears twice, because in dist/setup-config it exists
 only once:
  extraLibs = [clntsh]

Yes, puzzling. I don't know why you need to say -lclntsh, because
that's the point of all of this Setup shenanigans: to get things set
up so that ghci works nicely.

That's why we have flags that expose/hide modules in the API: ghci has
a custom linker, and this tries to link everything in the library, and
of course this fails if you don't have the .ddl/.so installed for a
particular backend. ghc uses gnu ld to link, and this does not try to
link unused modules, so this works fine with the entire library API
compiled.

Do you need to say -lclntsh when you use ghc to compile?


 Next step is to fetch real data from the database. But now I encounter new
 problems. If I write a real 'select' statement I get at best:

 Unexpected null in row 1, column 1.
 *** Exception: (unknown)

This looks like you are fetching a null value back with an iteratee
that does not expect nulls. We use Maybe to specify that a column in
the result-set can be null e.g.

  iter :: Int - Maybe Int - Maybe String - IterAct [(Int, Maybe
Int, Maybe String)]

The first column must never contain null. If it does then you get the
Unexpected null exception.


 and at worst:

 50001752
 *** glibc detected *** /usr/lib/ghc-6.8.2/ghc-6.8.2: free(): invalid
 pointer: 0x08d10065 ***
 === Backtrace: =

If this continues, can you provide a test case for me?

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-25 Thread Alistair Bayley
 $ ll $ORACLE_HOME/lib
 ...
 I assume that libociei.so is the library I need.

 Actually it's libclntsh.so. You need to change the oracle section in
 Takusen.cabal to this:

hand-slaps-forehead/

Another difference between Windows and Linux Oracle installations is
that the client libs are in $ORACLE_HOME/lib on Linux, but in
$ORACLE_HOME/bin on Windows. The Setup.hs script has the Windows case
baked in. You should change the configOracle function like so:

configOracle verbose buildtools =
  createConfigByFindingExe verbose buildtools Oracle sqlplusProgram
parentFolder oracleLibDir oci/include
-- location of OCI client library differs between Windows and Unix
where oracleLibDir = if isWindows then bin else lib


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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-25 Thread Alistair Bayley
 I'll have to change the way that Setup.hs tries to find $ORACLE_HOME.
 Using getEnv would be a much better idea. I don't recall why I didn't
 use it before; perhaps it's not always set on Windows installations.

Try this version of configOracle in Setup.hs:

configOracle verbose buildtools = do
  if not (sqlplusProgram `isElem` buildtools)
then return Nothing
else do
  path - getEnv ORACLE_HOME
  info verbose (Using Oracle:  ++ path)
  makeConfig path libDir oci/include
where libDir = if isWindows then bin else lib


You'll also need to add this import:

import System.Environment (getEnv)

I always used to get the Using... messages, but now it seems I need to say:
  $ setup configure -v -foracle

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Alistair Bayley
2008/6/24 Henning Thielemann [EMAIL PROTECTED]:

 (I remain on the list in order to fill the archive with information, others
 may need, too.)

As you wish.


 (Btw. Takusen should be split into
 several packages for all database backends because Cabal flags must not
 influence the package interface.)

I don't understand this (cabal flags must not influence package
interface). I thought that was the point of cabal flags? I wanted to
have a single package installation, and this seems like the best way.


 But on installation Cabal complains about missing /usr/oci directory.

When you run configure, you should get output that says:
Using Oracle: path

What is path?

The Setup.hs assumes the entire Oracle installation is under a single
root folder ($ORACLE_HOME); is this not true on Linux? If not, then we
will have to find some other way of locating the bin and include
folders. Perhaps we can do something like the Postgres installation,
where there is a program you can run which will print the include and
lib folders. That may mean a little hacking on Setup.hs, but there's
already a good example there for Postgres.


 Once I will get Takusen running with OCI - how would I use it? Is there a
 minimal example which connects to an Oracle database, performing a very
 simple query?

There's an example in the README.txt, which I've tweaked here for Oracle:

{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-overlapping-instances #-}
module Main where
import Database.Oracle.Enumerator
import Control.Monad.Trans (liftIO)
main = flip catchDB reportRethrow $
  withSession (connect user pswd dbname) (do
let iter (s::String) (_::String) = result s
result - doQuery (sql select 'Hello world.' from dual) iter 
liftIO (putStrLn result)
)

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-24 Thread Alistair Bayley
 2008/6/24 Henning Thielemann [EMAIL PROTECTED]:

 When you run configure, you should get output that says:
 Using Oracle: path

 What is path?

 I don't get these questions.

Sorry. I was really asking (not very clearly): what is the output from
runhaskell Setup.hs configure -foracle ? You've answered that below.


 Ah, I must have set ORACLE_HOME for the Takusen installation ... should be
 documented. However in my case, this doesn't change the path used by
 Takusen's Setup/install.

Well, you don't actually need it set for the Takusen install (it
doesn''t use it). But $ORACLE_HOME/bin should be in your path. And it
needs to contain the executable sqlplus. Can you run sqlplus? It looks
as though you don't have it.

If sqlplus is not in my path then I get this error in the configure
step, because I have specified sqlplus as a buildtool in
Takusen.cabal:

   setup configure -foracle
  Configuring Takusen-0.8.2...
  setup: sqlplus is required but it could not be found.

Note: sqlplus isn't really needed to build; this is just a validation
step, to check you have $ORACLE_HOME/bin in your path.


 $ echo $ORACLE_HOME
 /usr/lib/oracle/10.2.0.4/client
 $ ls $ORACLE_HOME
 bin  lib
 $ ll $ORACLE_HOME/lib
 ...
 I assume that libociei.so is the library I need.

Actually it's libclntsh.so. You need to change the oracle section in
Takusen.cabal to this:

  If flag(oracle)
Exposed-modules:
Database.Oracle.Enumerator
  , Database.Oracle.OCIConstants
  , Database.Oracle.OCIFunctions
Build-Tools: sqlplus
If os(windows)
  Extra-Libraries: oci
Else
  Extra-Libraries: clntsh

Your $ORACLE_HOME installation looks fairly normal, if somewhat
minimal. I would normally expect to see sqlplus, and maybe some other
executables, like tnsping. And a folder $ORACLE_HOME/oci/include,
which contains the OCI header files. Perhaps you could also install
the sqplus and SDK packages, as Lanny Ripple suggested, although I
suspect they may not be strictly necessary, as you can apparently
successfully compile, as evidenced below.

 $ runhaskell Setup.hs configure --user -f oracle
 Configuring Takusen-0.8.2...

Here, I would expect to see Using Oracle: /usr/lib/oracle/10.2.0.4/client

After setup configure you can say:
  $ runhaskell Setup.hs register --gen-pkg-config

and then take a look at the generated Takusen-0.8.2.conf. Check the
library-dirs and include-dirs fields.

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-20 Thread Alistair Bayley
2008/6/20 Alistair Bayley [EMAIL PROTECTED]:
 Is there a way of accessing a remote Oracle database by one of the common
 Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get
 unixODBC and Oracle's Instant Client running on a Linux machine, but I'm
 trapped in the notorious error:

 Takusen's Oracle backend uses the Oracle Call Interface (OCI) library
 directly. I think most Oracle client drivers (ODBC, ADO.Net, etc) use
 the OCI. I don't know what the Oracle Instant Client is; I'll assume
 that it includes an oci.so or liboci.so. On Windows, with which I am
 most familiar, the Oracle client software is all installed in
 $ORACLE_HOME, and the OCI library is $ORACLE_HOME/bin/oci.dll. If you
 can locate that, then you ought to be able to use Takusen with it.

Having just taken a closer took at what Oracle Instant Client is, I
suspect that you might have some trouble getting Takusen to compile
against it. The Instant Client lacks header files, while Takusen's FFI
imports specify oci.h. I don't know what happens if ghc can't find the
header files. Oracle do state that the Instant Client is for
deployment only; developers (that means you) will need the full client
installation.

Another problem is that the Oracle installation process assumes that,
for all platforms, the library is called oci i.e. the linker option
-loci is used. For Unix clients, the OCI library seems to be
libclnstsh.so, so I guess it should pass -lclnstsh. This highlights
the lack of testing on non-Windows platforms. If you'd like to help
get this working better, perhaps we can discuss off-list.

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


Re: [Haskell-cafe] Access to Oracle database from Haskell

2008-06-19 Thread Alistair Bayley
 Is there a way of accessing a remote Oracle database by one of the common
 Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get
 unixODBC and Oracle's Instant Client running on a Linux machine, but I'm
 trapped in the notorious error:

Takusen's Oracle backend uses the Oracle Call Interface (OCI) library
directly. I think most Oracle client drivers (ODBC, ADO.Net, etc) use
the OCI. I don't know what the Oracle Instant Client is; I'll assume
that it includes an oci.so or liboci.so. On Windows, with which I am
most familiar, the Oracle client software is all installed in
$ORACLE_HOME, and the OCI library is $ORACLE_HOME/bin/oci.dll. If you
can locate that, then you ought to be able to use Takusen with it.

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


Re: Haddock, .lhs, and GHC

2008-06-16 Thread Alistair Bayley
 I never thought about that.  I've been using Setup.hs with #!/usr/bin/env
 runhaskell and never had any problems.

 I guess the only thing that would be gained by using Setup.lhs is the
 ability to compile the setup program.  Is that something that's commonly
 done?

That's what I do. My normal install procedure is:
  ghc --make setup
  setup configure
  setup build
  setup install

If only takes a couple of seconds for ghc to compile setup, and then
it runs instantly. If I was to use runghc then it would recompile (in
ghci) for each invocation.

I use #! in Setup.hs (non-lit) and it compiles fine, so no worries there either.

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


Re: [Haskell-cafe] What to do when GHC works, RUNGHC fails

2008-05-23 Thread Alistair Bayley
2008/5/23 Peter Verswyvelen [EMAIL PROTECTED]:
 So it seems the GHCi linker is not using the metadata in the library file 
 correctly? The libpng.dll.a library file clearly contains a reference to 
 libpng3.dll, and I guess since GHC is using the GCC linker, this works fine, 
 but GHCi most likely has its own linker?

 If this is correct, we should file a bug report?

This seems to be the same bug:
  http://hackage.haskell.org/trac/ghc/ticket/1883

The ghci linker is a custom one (AFAIK) and is different from GNU
ld. That's a feature, not a bug :-) GNU ld, for example, can find
either of libxxx.dll or xxx.dll if you say -lxxx.

See this ticket for another difference between ghci and GNU ld (ghci's
linker tries to link _all_ symbols in the library archive, rather than
just the modules that you're using):
  http://hackage.haskell.org/trac/ghc/ticket/1477

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


[Haskell-cafe] Std lib equivalent for liftM concat . sequence

2008-05-16 Thread Alistair Bayley
A couple of days ago I had need for:

 concatM :: Monad m = [m [a]] - m [a]
 concatM = liftM concat . sequence

but found no such thing in the std libs, except perhaps for msum (I
don't want to add instances for MonadPlus. Should I have to?). Have I
missed something trivial?

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


[Haskell-cafe] ANN: Takusen 0.8.1

2008-03-21 Thread Alistair Bayley
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Takusen-0.8.1

This is a fairly minor bugfix release. although there are some API
changes. Mainly, we've re-exported a lot of the types from
Database.InternalEnumerator in Database.Enumerator. This will
hopefully address a common complaint that it's impossible to always
write type sigs for functions doing database stuff.

We've also tidied up some of the exports; there was stuff exposed that
shouldn't have been.

There's an outstanding bug involving datetime parameter marshaling in
ODBC, which I have not had time to resolve (parameters after the
datetime parameter get mangled somehow). I will be on holiday for a
few weeks, so this will not be addressed by me for some time. Caveat
user. The test suite highlights it, should someone else feel
sufficiently motivated; I've been testing against PostgreSQL.

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


Re: [Haskell-cafe] Need Cabal/library building help for windows

2008-03-18 Thread Alistair Bayley
On 17/03/2008, Felix Martini [EMAIL PROTECTED] wrote:
 Ryan Ingram wrote:
   For reference, I'm using GHC6.8.1 on WinXP.

   setup.hs: ld is required but it could not be found.

 I did have the same issue with GHC 6.8.1 on Windows. It is fixed in
  version 6.8.2.

  http://haskell.org/ghc/download_ghc_682.html#windows

Upgrading GHC to fix this seems a little extreme. You can just add
gcc-lib (i.e. C:\ghc\ghc-6.8.1\gcc-lib) to your path.

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


Re: [Haskell-cafe] haddock as a markdown preprocessor

2008-02-21 Thread Alistair Bayley
On 21/02/2008, Duncan Coutts [EMAIL PROTECTED] wrote:

 To be honest I like the fact that haddock's markup is really simple and
  perhaps somewhat restrictive. A great improvement though would be to
  make it easy to extract the docs from haddock in a nice format so that
  the could be re-used in other contexts rather than just generating html
  api documentation. Haddock does have support for multiple backends,
  someone just needs to define and write a generic backend that spits out
  the info that haddock gathers in a machine readable format.

I have probably misunderstood both of you, but I think that Conal
proposed that Haddock *input* syntax is largely unchanged; Haddock
should be able to *output* markdown, for consumption by pandoc.

(Which I think is also what you're suggesting.)

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


Re: [Haskell-cafe] ANN: Leksah 0.1 - Haskell IDE written in Haskell

2008-02-14 Thread Alistair Bayley
  Leksah is written by me and published under a GPL-2 license.
  Leksah can be optained via Hackage: http://hackage.haskell.org/
  Darcs development repository: http://code.haskell.org/leksah

I just downloaded this from hackage and went through the usual Cabal
ritual. The build fails with

[16 of 41] Compiling IDE.Utils.File   ( src/IDE/Utils/File.hs,
dist\build\leksah\leksah-tmp/IDE/Utils/File.o )

src/IDE/Utils/File.hs:161:33:
Couldn't match expected type `Either String String'
   against inferred type `String'
In the expression:
if takeExtension fp == .lhs then unlit fp str else str
In the definition of `str'':
str' = if takeExtension fp == .lhs then unlit fp str else str
In the expression:
if exists then
do str - readFile fp
   let str' = ...
   let parseRes = ...
   
else
return Nothing


Would I be better off getting straight from the darcs repo?

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


Re: [Haskell-cafe] ANN: Leksah 0.1 - Haskell IDE written in Haskell

2008-02-14 Thread Alistair Bayley
On 14/02/2008, Alistair Bayley [EMAIL PROTECTED] wrote:

  src/IDE/Utils/File.hs:161:33:
 Couldn't match expected type `Either String String'
against inferred type `String'

Never mind; I've just realised this is because I have the latest dev
version of Cabal installed.

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


Re: code.haskell.org vs darcs.haskell.org (was [Haskell-cafe] Enterprise Haskell AMQP library)

2008-01-29 Thread Alistair Bayley
On 29/01/2008, Henning Thielemann [EMAIL PROTECTED] wrote:

 Thanks for the clarification! I added it to
   http://www.haskell.org/haskellwiki/Haskell.org_domain
  Can you insert the link to the web-submission system?

I've done this.

I also tried to request an account on code.haskell.org, but the server
complains about my public key:

  500 Internal Server Error
  SSH key looks incorrect

I pasted the key from this path (I use Putty and Pagaent on WinXP):
  C:\bayleya\putty\putty\id_dsa_pub.txt

This folder also contains id_dsa.ppk (that's what Pagaent uses), which
contains the same key, and also the private bit. The public key looks
like this:

 BEGIN SSH2 PUBLIC KEY 
Comment: dsa-key-20040309
B3NzaC1kc3MAAACBAKs9yeNP35s4rSBDlJKQCC1nemVGd0zQAROFKeziCOGm
blah blah blah
W5zrOSga/U/Cfa2rIM8Ko/9QmjNCJKsJioC5OTZMwOF0+zBWFCNN73z5+Dz/+PL+
Xw==
 END SSH2 PUBLIC KEY 

and this is what I've pasted into the form. I've also tried trimming
it (removing the -- BEGIN and END, and the Comment) but no joy. Is
this the right thing to put into the form? If not, where can I find
it?

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


[Haskell-cafe] Data.Generics: how do I get the type name of a value?

2007-12-14 Thread Alistair Bayley
I've been learning/playing with Data.Generics a bit, and have a how-to
question...

If I say
 dataTypeOf 
then I get
 DataType {tycon = Prelude.[], datarep = AlgRep [[],(:)]}

No surprises there. But I'd really like to know that I have a String,
or [Char]. How do I get the name of the concrete type that the list
contains? Is that a reasonable thing to ask for?

I can say:
 gmapQ dataTypeOf a
to get:
 [ DataType {tycon = Prelude.Char, datarep = StringRep}
 , DataType {tycon = Prelude.[], datarep = AlgRep [[],(:)]}
 ]

But if I say:
 gmapQ dataTypeOf 
I get:
 []

which makes sense when you consider the stucture of the List ADT, but
doesn't help me determine the type of the value.

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


Re: [Haskell-cafe] Data.Generics: how do I get the type name of a value?

2007-12-14 Thread Alistair Bayley
On 14/12/2007, Neil Mitchell [EMAIL PROTECTED] wrote:

  http://haskell.org/hoogle/?q=typeOf

 Another great thing is that this bit also works in Hugs, while the
 Data.Generics stuff is GHC only.

Great, thanks. Didn't occur to me to look further up the class hierarchy :-)

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


Re: [Haskell-cafe] Why is this strict in its arguments?

2007-12-06 Thread Alistair Bayley
 Use of isNothing and fromJust and a cascade of ifs is generally a poor
 sign, much better to use case:

 findAllPath pred (Branch lf r rt)
  | pred r =
  case (findAllPath pred lf,findAllPath pred rt) of
(Nothing,Nothing)   - Nothing
(Nothing,Just rtpaths)  - Just (map (r:) rtpaths)
(Just lfpaths,Nothing)  - Just (map (r:) lfpaths)
(Just lfpaths,Just rtpaths) - Just (map (r:) $ rtpaths ++
 lfpaths)
  | otherwise = Nothing

 the general pattern is : replace isNothing with a case match on Nothing,
 replace fromJust with a case match on Just, don't be afraid to case two
 expressions at once.


Nested Maybe cases put me in mind of the Maybe monad. Although in this
case it''s not trivial; we also need to involve the Maybe [a] instance
of Data.Monoid too (for the mappend function). I do wonder if I'm
abusing the monadic instances of Maybe though; is this really any
clearer than Jules' code?

(BTW, this has probably come up before, but wouldn't it be a little
bit nicer if when returned mzero rather than () in the do nothing
case?)

 when' :: MonadPlus m = Bool - m a - m a
 when' pred action = if pred then action else mzero

 findAllPath :: (a - Bool) - (BTree a) - Maybe [[a]]
 findAllPath pred (Leaf l) = when' (pred l) (return [[l]])
 findAllPath pred (Branch lf r rt) =
   when' (pred r) $ do
 x - mappend (findAllPath pred lf) (findAllPath pred rt)
 return (map (r:) x)


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


GHC's CPP and Cabal's unlit

2007-11-28 Thread Alistair Bayley
I'm doing some testing with GHC 6.6.1 and Cabal 1.3, and I'm trying to
figure out what happens with CPP and Cabal's unlit.

I start with file Test.lhs:

 {-# OPTIONS -fglasgow-exts #-}
 module Test where
 main = putStrLn hello CPP

and run command:
  ghc -E -x hs -cpp Test.lhs -o Test2.lhs

which gives me Test2.lhs:

{-# LINE 1 Test.lhs #-}
# 1 Test.lhs
# 1 built-in
# 1 command line
# 1 Test.lhs
 {-# OPTIONS -fglasgow-exts #-}
 module Test where
 main = putStrLn hello CPP


So I'm wondering: where does the {-# LINE #-} comment come from, and
also the # 1 lines? AFAICT the # 1 lines are ignored by GHC; I can
compile Test2.lhs without errors. Is there anything in GHC's docs
about this?

More puzzling is that the files that Cabal runs through ghc's CPP
don't get the # n lines, so we end up with something like this:

{-# LINE 1 Test.lhs #-}
 {-# OPTIONS -fglasgow-exts #-}
 module Test where
 main = putStrLn hello CPP

which is not a valid .lhs file, because we have a code line next to a comment.

I also note in Cabal the haddock command runs CPP before unlit. GHC
does it the other way around i.e. run unlit first then CPP, and I'm
wondering if Cabal shouldn't do the same thing?

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


Re: GHC's CPP and Cabal's unlit

2007-11-28 Thread Alistair Bayley
 More puzzling is that the files that Cabal runs through ghc's CPP
 don't get the # n lines, so we end up with something like this:

(Answering my own message)

Having done some more testing with ghc-6.8.1 and ghc-6.6.1 and cabal's
1.1.6.2 and 1.3, I've realised that the cpp optP-P option in Cabal-1.3
is suppressing the # n lines, so that means the {-# LINE 1 Test.lhs
#-} comment does indeed end up immediately preceding the first real
line of the program (thus causing unlit to spit the dummy).

I've also noticed that the options passed from cabal-1.1.6.2 to the
ghc cpp phase do NOT include -x hs, so ghc unlits the file before
cabal then tries to unlit it. Surely this cannot work, and indeed it
does not, because the resulting .hs file contains no code.

I'm of a mind to fix two things in cabal:
 - the haddock command runs unlit first, THEN cpp
 - the unlit module preserves comments, for the benefit of haddock

I already have these done in my local Cabal-1.3, so creating patches
ought to be straightforward. I've only tested with ghc on Windows
though.

Comments?

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


Re: [Haskell-cafe] Cabal and DB packages

2007-11-25 Thread Alistair Bayley
On 25/11/2007, Thomas Schilling [EMAIL PROTECTED] wrote:
 On Sun, 2007-11-25 at 18:49 +0100, manu wrote:
  Hello,
 
  I'm trying to do something that should be fairly simple, installing
  some DB package so I can use MySQL or SQLite.
 
  with Takusen :
 
  $ runhaskell Setup.hs configure
 
  Setup.hs:26:7:
   Could not find module `Distribution.Program':
 Use -v to see a list of the files searched for.
 
  I give up...
 
  

 That means that Takusen requires an older Cabal.  I'd have to look at
 the code to see how hard it would be to fix this.

Um, yes. We haven't tested Takusen with ghc-6.8.1 yet, but it's on the list...

Our Setup.hs is a bit involved at present, and soon I hope to simplify
it quite a bit. There's a load of stuff in there just to get it to
build Haddock docs, which will be gone soon.

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-08 Thread Alistair Bayley
On 05/10/2007, Andrew Coppin [EMAIL PROTECTED] wrote:
 
  So the question becomes: do you want to attract/seduce this kind of
  programmer? Let's assume the answer is yes :-)

 Um... that assumpion troubles me.
 ...
 I think if we want to get anywhere we need to look at targeting people
 whom Haskell actually has something to offer. Now, if I could just
 figure out who those are... :-/

And:

On 05/10/2007, Jonathan Cast [EMAIL PROTECTED] wrote:
 On Fri, 2007-10-05 at 20:19 +, Aaron Denney wrote:
  On 2007-10-05, Peter Verswyvelen [EMAIL PROTECTED] wrote:
   If you want to attract more people that are inside the
   imperative-OO-with-nice-IDE-blob, create a great looking and
   functional IDE.
 
  Bluntly, I don't see why the Haskell community needs those sorts of
  programmers.

 Hear, hear.  At the company I work for, all the code is perl/web
 development --- and we wouldn't dream of hiring one of those
 programmers.


I posed the question: do we want to attract this kind of programmer?
My personal opinion, which some of you obviously don't share, is yes.

It isn't about whether or not the Haskell community needs those sorts
of programmers. It's whether or not those sorts of programmers need
Haskell.

For me, a large part of Haskell's attraction are the features which
reflect good engineering practice: strong, static type checking;
purely functional code; good FFI. It should be easier to write simple,
reliable software in Haskell than in most other languages; IMO,
getting the unwashed hordes to use Haskell would be a great
improvement in software industry productivity.

I realise that a large influx of mediocre programmers will have a
negative effect on the community, but is that a reasonable price to
pay? I understand that may of you love a small, intimate, high-quality
community, but perhaps that will have to evolve if we really want to
conquer the world.

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


Re: [Haskell-cafe] New slogan for haskell.org

2007-10-08 Thread Alistair Bayley
On 08/10/2007, Henning Thielemann [EMAIL PROTECTED] wrote:

 You cannot turn any programmer into a disciplined programmer just by
 giving him a well designed language. I you try so, they will not like to
 use that language, will leave that language as soon as possible or they
 try to adapt the language to their style of programming.

Well, I wasn't suggesting you'll create great programmers overnight,
but you might expect that their appreciation of good design might
improve after some Haskell exposure. Also, Haskell simply doesn't
support some of the things that are common causes of errors in the
enterprisey-language world. I recall reading something about one of
the most common causes of errors in novice programs being type errors
(presumably, once they'd got the program to compile i.e. there were no
syntactic errors). And I'm under the (possibly mistaken) impression
that some of the common errors non-novice programmers make are
aliasing bugs, and/or use of global variables. Does anyone have
references to studies confirming (or refuting) this?

 People who are used to weak typing will use a type like
data Number = Int Int | Float Float | ...
   for numbers, or even String for everything, they will use numbers, where
 enumerations are more appropriate and so on.

I think that the ease with which you can create a new type in Haskell
(and derive useful classes like Enum, Show, etc) makes it more likely
that a programmer will use an appropriate domain-specific type, rather
than just reuse String, Int, or Float.

 In my experience only the other way round works: Let people use C, Perl
 and Python until they find their programs unmaintainable. Then they will
 become interested in style and discipline and programming languages which
 _support_ good style.

Well, yes. Or have them learn Haskell, and *then* C/C#/C++/Java/Perl
etc, and see if the experience for those languages is as good. I like
to think they'll come running back to Haskell's warm bosom.

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


Re: [Haskell-cafe] Re: Error building takusen with Cabal-1.1.6.2

2007-08-19 Thread Alistair Bayley
  Setup.hs:13:7:
  Could not find module `Distribution.Compat.FilePath':
it is hidden (in package Cabal-1.1.6.2)

 This is what I did to make takusen build with ghc-6.6.1:

 [EMAIL PROTECTED]: .../haskell/takusen_0  darcs whatsnew
 {
 hunk ./Setup.hs 13
 -import Distribution.Compat.FilePath (splitFileName, joinPaths)^M$
 +import System.FilePath (splitFileName, combine)^M$
 hunk ./Setup.hs 124
 -  libDirs - canonicalizePath (joinPaths path libDir)^M$
 -  includeDirs - canonicalizePath (joinPaths path includeDir)^M$
 +  libDirs - canonicalizePath (combine path libDir)^M$
 +  includeDirs - canonicalizePath (combine path includeDir)^M$
 }

 HTH
 Ben


I've pushed changes to the Setup scripts (and the README.txt) in the
darcs report so that it should build out-of-the-box. Just pull the
latest code.

However, I'm off on holiday (more-or-less unaccessable) for a couple
of weeks on Monday, so if I've busted it badly, I apologize in
advance.

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


Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-07-22 Thread Alistair Bayley

Hello cafe,

(Following up on my own optimisation question, and Duncan's advice
to look at http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs)


If you want to look at some existing optimised UTF8 encoding/decoding
code then take a look at the code used in GHC:

http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs

Duncan


I took a look at the UTF8 decoder in GHC. This inspired me to write
one that also used unboxed types directly. Pleasingly, it goes like
a cut cat, and uses far less space than the naive version, but it's
not portable, which is a bummer.

(The docs tell me that using GHC.Exts is the approved way of
accessing GHC-specific extensions, but all of the useful stuff seems
to be in GHC.Prim.)

After some expriments with the simplifier, I think I have a portable
version of a direct-from-buffer decoder which seems to perform nearly
as well as one written directly against GHC primitive unboxed functions.
I'm wondering if there's anything further I can do to improve performance.
The portable unboxed version is within about 15% of the unboxed version
in terms of time and allocation.

Changes I made:
- added strictness annotations in the form of a strictness guards
  that are always False
- unrolled loops (they were always short loops anyway, with a maximum
  of 3 or 4 iterations)
- replaced shiftL with multiplication, because multiplication unboxes,
  while shiftL doesn't.

Some things I've noticed in the simplifier output:
- the shiftL call hasn't unboxed or inlined into a call to
  uncheckedShiftL#, which I would prefer.
  Would this be possible if we added unchecked versions of
  the shiftL/R functions to Data.Bits?
- Ptrs don't get unboxed. Why is this? Some IO monad thing?
- the chr function tests that its Int argument is less than 1114111,
  before constructing the Char. It'd be nice to avoid this test.
- why does this code:

 | x = 0xF7 = remaining 3 (bAND x 0x07) xs
 | otherwise = err x

  turn into this
  i.e. the = turns into two identical case-branches, using eqword#
  and ltword#, rather than one case-branch using leword# ?

 case GHC.Prim.eqWord# a11_a2PJ __word 247 of wild25_X2SU {
   GHC.Base.False -
 case GHC.Prim.ltWord# a11_a2PJ __word 247 of wild6_Xcw {
   GHC.Base.False - error call
   GHC.Base.True -
 $wremaining_r3dD
   3
   (__scc {fromUTF8 main:Foreign.C.UTF8 !}
GHC.Base.I# (GHC.Prim.word2Int# (GHC.Prim.and# a11_a2PJ __word 7)))
   xs_aVm
 };
   GHC.Base.True -
 $wremaining_r3dD
   3
   (__scc {fromUTF8 main:Foreign.C.UTF8 !}
GHC.Base.I# (GHC.Prim.word2Int# (GHC.Prim.and# a11_a2PJ __word 7)))
   xs_aVm
 };


BTW, what's the difference between the indexXxxxOffAddr# and
readXxxxOffAddr# functions in GHC.Prim? AFAICT they are equivalent,
except that the read* functions take an extra State# s parameter.
Presumably this is to thread the IO monad's RealWorld value through,
to create some sort of data dependency between the functions (and so
to ensure ordered evaluation?)

Alistair

{-# OPTIONS_GHC -fglasgow-exts #-}

-- |
-- Module  :  Foreign.C.UTF8
-- Copyright   :  (c) 2004 John Meacham, Alistair Bayley
-- License :  BSD-style
-- Maintainer  :  [EMAIL PROTECTED]
-- Stability   :  experimental
-- Portability :  portable
--
-- Marshall Haskell Strings to and from UTF8-encoded CStrings.
-- This module's code is inspired by John Meacham's UTF8 en-  de-coders,
-- and also those found in the HXT library (module Text.XML.HXT.DOM.Unicode).
-- 
-- Note that the -Len functions all return the length in bytes,
-- not Chars (this is more useful, as you are most likely to want
-- to pass the length to an FFI function, which is most likely
-- expecting the length in bytes). If you want the length in Chars,
-- well, you have the original String, so...


module Foreign.C.UTF8
  ( peekUTF8String, peekUTF8StringLen
  , peekUTF8StringB, peekUTF8StringLenB
  , newUTF8String, withUTF8String, withUTF8StringLen
  , toUTF8String, fromUTF8String
  , lengthUTF8, fromUTF8, toUTF8
  ) where

import Control.Monad (when, liftM)
import Data.Bits
import Data.Char
import Data.Word (Word8)
import Foreign.C.Types
import Foreign.C.String
import Foreign.Ptr
import Foreign.Marshal.Array
import Foreign.Storable
import GHC.Base
import GHC.Ptr (Ptr(..))

nullCChar :: CChar
nullCChar = 0

nullByte :: Word8
nullByte = 0

-- | Analogous to peekCString. Converts UTF8 CString to String.
peekUTF8String :: CString - IO String
peekUTF8String cs = peekArray0 nullByte (castPtr cs) = return . fromUTF8

peekUTF8StringB :: CString - IO String
peekUTF8StringB cs = fromUTF8Ptr0 (castPtr cs)

-- | Analogous to peekCStringLen. Converts UTF8 CString to String.
-- The resulting String will end either when @len@ bytes
-- have been converted, or when a NULL is found.
peekUTF8StringLen :: CStringLen - IO String
peekUTF8StringLen (cs, len) = peekArray len (castPtr cs) = return . fromUTF8

peekUTF8StringLenB :: CStringLen - IO String

Re: [Haskell-cafe] haskell - db, on Solaris

2007-07-11 Thread Alistair Bayley

 
http://www.haskell.org/haskellwiki/Applications_and_libraries/Database_interfaces

 If you want to talk to MySQL, you have a few choices.

 HDBC has an ODBC interface that lets you use any ODBC provider, so
 you'll be able to talk to both MySQL and Oracle with it.

 HaskellDB can bridge to HDBC, I believe, so that will let you do
 type-safe SQL.

 There's also Takusen, which can talk to Oracle, but not MySQL.

Yes, thanks. But the emphasis was on Solaris. I don't quite understand
what is the common way to access databases on Solaris. Is it odbc? And
how Haskell libraries connect to that? I mean, Takusen is designed to
use odbc and nothing else (afaik), for example.


Takusen uses OCI to talk to Oracle, so it should work on any Oracle (
GHC) platform. However, no ODBC or MySQL backend yet (I'm working on
ODBC right now, but it's slow going...).

I imagine that the common way to access databases on Solaris is the
same as on other Unix platforms, which is probably to use the vendor's
API directly. There is also http://www.unixodbc.org/, which appears to
support Solaris, but I can't vouch for it from a usability perspective
i.e. how hard is it to get working, and to get working with HDBC or
HSQL.

I'd recommend giving unixodbc + hsql/hdbc a go, and let us know of any problems.

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


Re: [Haskell-cafe] sha1 implementation thats only 12 times slower then C

2007-07-03 Thread Alistair Bayley

On 03/07/07, Anatoly Yakovenko [EMAIL PROTECTED] wrote:

inlining some of the functions definitely gave me a boost, so i am
about 8.5 times slower then openssl sha1sum.  I dont really understand
the core output, but after inlining i got a completely different
profile output, i am guessing its because the cost of the inlined
functions is spread to the callers.


Are you using -auto, or -auto-all? Because it makes a difference to
the generated core, and the extent to which inlining takes place. I've
noticed that -auto permits more inlining than -auto-all, so try -auto
if you can. Also, follow the advice in the GHC manual, and only export
the functions you need to. This will aid both the inliner and
specialiser enormously.

As for reading core (well, actually simplifier output; core has less
punctuation), these links might help:

4.16.3. How to read Core syntax
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html#id3130643

(and the Encoding module has the actual rules for the Unique names)
http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs

6.2. Faster: producing a program that runs quicker
http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html
(see How do I find out a function's strictness?)

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


Re: [Haskell-cafe] Building Yi (and wider Cabal stuff)

2007-06-17 Thread Alistair Bayley

I'm trying to build Yi (from the darcs repository) to take a look at it.  The README that 
comes with it says it's a standard Cabal project so do what you normally do 
(paraphrased slightly).  The problem is that I'm not a cabal user just yet and have no 
idea where to go from here.


The standard cabal usage is:
 runhaskell Setup.hs configure
 runhaskell Setup.hs build
 runhaskell Setup.hs install


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

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


Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-15 Thread Alistair Bayley

Simon,

Sorry for the delay on responding.


I'm using 6.6, so I'll upgrade to 6.6.1 and retest. Preusmably you're
only interested if this behaviour persists in 6.6.1. I'll check both
cases and make a test cases for them if necessary.


I've upgraded to 6.6.1 and am pleased to report that there appears to
be no difference between seq and bang-patterns in the simplifier output.

As for the other case (where a function results in two functions in the
simplifier output, which appear to be some sort of worker-wrapper pair),
a module is attached which gives this behaviour.

I compiled it with:
 ghc -c UTF8.hs -O2 -prof -auto -ddump-simpl

Look for $s$wfromUTF8Ptr and $wfromUTF8Ptr.

I also notice that with -auto-all, the function readUTF8Char appears in
the simplifier output, but with -auto it is inlined into fromUTF8Ptr, and
so vanishes from the simplifier output.

Running my test case compiled with -auto seems to gives run times at about
70-80% of -auto-all, and allocation is 40% (!) of -auto-all; that's a
significant difference.

Alistair

module UTF8
  ( peekUTF8String, peekUTF8StringLen
  ) where

import Control.Monad (when, liftM)
import Data.Char
import Data.Word (Word8)
import Foreign.C.String
import Foreign.Ptr
import Foreign.Marshal.Array
import Foreign.Storable
import GHC.Base (unsafeChr)


nullByte :: Word8
nullByte = 0

peekUTF8String :: CString - IO String
peekUTF8String cs = fromUTF8Ptr0 (castPtr cs)

peekUTF8StringLen :: CStringLen - IO String
peekUTF8StringLen (cs, len) = fromUTF8Ptr (len-1) (castPtr cs) 


fromUTF8Ptr0 :: Ptr Word8 - IO String
fromUTF8Ptr0 p = do
  len - lengthArray0 nullByte p
  fromUTF8Ptr (len-1) p 

fromUTF8Ptr :: Int - Ptr Word8 - String - IO String
fromUTF8Ptr bytes p acc
  | () `seq` bytes `seq` p `seq` acc `seq` False = undefined
  | bytes  0 = return acc
  | otherwise = do
  x - liftM fromIntegral (peekElemOff p bytes)
  case () of
_ | x == 0 - error (fromUTF8Ptr: zero byte found in string as position  ++ show bytes)
  | x = 0x7F - fromUTF8Ptr (bytes-1) p (unsafeChr x:acc)
  | x = 0xBF  bytes == 0 - error fromUTF8Ptr: surrogate at start of string
  | x = 0xBF - fromUTF8Ptr (bytes-1) p acc
  | otherwise - do
  c - readUTF8Char x bytes p
  fromUTF8Ptr (bytes-1) p (c:acc)


readUTF8Char :: Int - Int - Ptr Word8 - IO Char
readUTF8Char x offset p
  | () `seq` x `seq` offset `seq` p `seq` False = undefined
  | otherwise =
  case () of
_ | x == 0 - err x
  | x = 0x7F - return (unsafeChr x)
  | x = 0xBF - err x
  | x = 0xDF - do
  x1 - liftM fromIntegral (peekElemOff p (offset + 1))
  return (unsafeChr (
((x - 0xC0) * 64)
+ (x1 - 0x80)
))
  | x = 0xEF - do
  x1 - liftM fromIntegral (peekElemOff p (offset + 1))
  x2 - liftM fromIntegral (peekElemOff p (offset + 2))
  return (unsafeChr (
((x - 0xE0) * 4096)
+ ((x1 - 0x80) * 64)
+ (x2 - 0x80)
))
  | x = 0xF7 - do
  x1 - liftM fromIntegral (peekElemOff p (offset + 1))
  x2 - liftM fromIntegral (peekElemOff p (offset + 2))
  x3 - liftM fromIntegral (peekElemOff p (offset + 3))
  return (unsafeChr (
((x - 0xF0) * 262144)
+ ((x1 - 0x80) * 4096)
+ ((x2 - 0x80) * 64)
+ (x3 - 0x80)
))
 | otherwise - err x
  where
err x = error (readUTF8Char: illegal UTF-8 character  ++ show x)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-08 Thread Alistair Bayley

Simon,


You're right, both versions should give the same code.  Which version of GHC 
are you using?  Both with the HEAD and with 6.6.1 I get the nice unboxed code 
with the `seq` version too.  My test program is below.


I'm using 6.6, so I'll upgrade to 6.6.1 and retest. Preusmably you're
only interested if this behaviour persists in 6.6.1. I'll check both
cases and make a test cases for them if necessary.

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


Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-05 Thread Alistair Bayley

   {- Arity: 4 Strictness: LSSL -}

Right. Unboxed args are always given the annotation L. So that function
is strict in that pointer arg, but GHC is choosing not to unbox it. I'm
not sure why that's the case.


I thought maybe it was because I hadn't said -funbox-strict-fields,
but it didn't change when I did.



 Is there some semantic advantage to bang-patterns, or is it just a
 syntactic convenience?

It's syntactic convenience.


I've noticed differences between strictness guards and bang-patterns
with GHC. This is a problem, I think, because bang-patterns are GHC
only, and I wanted to keep the code portable. This strictness guard:

readUTF8Char :: Int - Int - Ptr Word8 - IO Char
readUTF8Char x offset p
 | () !x !offset !p !False = undefined
 | otherwise =
 ...
 where
   x ! y = seq x y

results in this simplifier output:

[Arity 3
Str: DmdType LSS]
$wreadUTF8Char_r38I =
 \ (ww_s30B :: GHC.Prim.Int#)
   (w_s30D :: GHC.Base.Int)
   (w1_s30E :: GHC.Ptr.Ptr GHC.Word.Word8) -


However, if I change this to:

{-# OPTIONS_GHC -fbang-patterns #-}

...

readUTF8Char :: Int - Int - Ptr Word8 - IO Char
readUTF8Char !x !offset !p
 | otherwise =


then I get this simpifier output:

[Arity 3
Str: DmdType LLL]
$wreadUTF8Char_r38n =
 \ (ww_s2Zk :: GHC.Prim.Int#)
   (ww1_s2Zo :: GHC.Prim.Int#)
   (ww2_s2Zs :: GHC.Prim.Addr#) -


Also, with bang-patterns I've noticed that fromUTF8Ptr transforms
into two functions, which contain very similar code:

[Arity 5]
Foreign.C.UTF8.$s$wfromUTF8Ptr =
 \ (acc_X151 :: GHC.Base.String)
   (new_s_a2GQ :: GHC.Prim.State# GHC.Prim.RealWorld)
   (a87_a2GR :: GHC.Base.Char)
   (ww_s2ZH :: GHC.Prim.Addr#)
   (sc_s36j :: GHC.Prim.Int#) -

[Arity 4
Str: DmdType LLSL]
Foreign.C.UTF8.$wfromUTF8Ptr =
 \ (ww_s2ZD :: GHC.Prim.Int#)
   (ww1_s2ZH :: GHC.Prim.Addr#)
   (w_s2ZJ :: GHC.Base.String)
   (w1_s2ZK :: GHC.Prim.State# GHC.Prim.RealWorld) -


$wfromUTF8Ptr calls itself and $s$wfromUTF8Ptr, but $s$wfromUTF8Ptr
only every calls itself, so $wfromUTF8Ptr could be considered the
wrapper, and $s$wfromUTF8Ptr the worker, I guess.

AFAICT it's a transformation of the various cases in fromUTF8Ptr:

 | x = 0x7F - fromUTF8Ptr (bytes-1) p (chr x:acc)
 | x = 0xBF  bytes == 0 - error fromUTF8Ptr: ...
 | x = 0xBF - fromUTF8Ptr (bytes-1) p acc
 | otherwise - do
 c - readUTF8Char x bytes p
 fromUTF8Ptr (bytes-1) p (c:acc)

The first case, x = 0x7F, results in a call to $s$wfromUTF8Ptr.
The third case, x = 0xBF, results in a call to $wfromUTF8Ptr.
The last case, otherwise, results in a call to $s$wfromUTF8Ptr.

The calls to $s$wfromUTF8Ptr pass the newly constructed Char and the
rest of the String separately, and they are cons'ed in $s$wfromUTF8Ptr.
Not sure what benefit this gives...

I don't know what transformation causes this, but it was a bit of a surprise.

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


Re: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-04 Thread Alistair Bayley

On 04/06/07, Duncan Coutts [EMAIL PROTECTED] wrote:

On Mon, 2007-06-04 at 09:43 +0100, Alistair Bayley wrote:

 After some experiments with the simplifier, ...
 The portable unboxed version is within about 15% of the unboxed version
 in terms of time and allocation.

Well done.


Of course, that might be saying more about the performance of the
unboxed version...



Yeah. In Data.ByteString.Char8 we invent this w2c  c2w functions to
avoid the test. There should probably be a standard version of this
unchecked conversion.


Bulat suggested unsafeChr from GHC.Exts, but I can't see this. I guess
I could roll my own; after all it's just (C# (chr# x)).



 BTW, what's the difference between the indexXxxxOffAddr# and
 readXxxxOffAddr# functions in GHC.Prim?

Right. So it'd only be safe to use the index ones on immutable arrays
because there's no way to enforce sequencing with respect to array
writes when using the index version.


In this case I'm reading from a CString buffer, which is (hopefully)
not changing during the function invocation, and never written to by
my code. So presumably it'd be pretty safe to use the index-
functions.



  - Ptrs don't get unboxed. Why is this? Some IO monad thing?

Got any more detail?


OK. readUTF8Char's transformation starts with this:

$wreadUTF8Char_r3de =
 \ (ww_s33v :: GHC.Prim.Int#) (w_s33x :: GHC.Ptr.Ptr GHC.Word.Word8) -

If we expect it to unbox, I'd expect the Ptr to become Addr#. Later,
this (w_s33x) gets unboxed just before it's used:

 case w_s33x of wild6_a2JM { GHC.Ptr.Ptr a_a2JO -
 case GHC.Prim.readWord8OffAddr# @ GHC.Prim.RealWorld a_a2JO 1 s_a2Jf

readUTF8Char is called by fromUTF8Ptr, where there's a little Ptr
arithmetic. The Ptr argument to fromUTF8Ptr is unboxed, offset is
added, and the result is reboxed so that it can be consumed by
readUTF8Char. All a bit unnecessary, I think e.g.

Foreign.C.UTF8.$wfromUTF8Ptr =
   ...
   let {
 p'_s38N [Just D(T)] :: GHC.Ptr.Ptr GHC.Word.Word8
 [Str: DmdType]
 p'_s38N =
__scc {fromUTF8Ptr main:Foreign.C.UTF8 !}
case w_s33J of wild11_a2DW { GHC.Ptr.Ptr addr_a2DY -
GHC.Ptr.Ptr @ GHC.Word.Word8 (GHC.Prim.plusAddr# addr_a2DY ww_s33H)
}
   } in
   ...

I'd prefer the Ptr arg to fromUTF8Ptr to also be unboxed, so that the
primitive plusAddr# can be used directly on it before it's passed to
readUTF8Char. Perhaps instead I could push this Ptr arithmetic down to
readUTF8Char, and pass it the constant Ptr to the start of the buffer,
and the offset into it, rather than a Ptr to the current position.

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


Fwd: [Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-06-04 Thread Alistair Bayley

(this time include the list, too)

-- Forwarded message --
From: Alistair Bayley [EMAIL PROTECTED]
Date: 04-Jun-2007 16:13
Subject: Re: [Haskell-cafe] Optimising UTF8-CString - String
marshaling, plus comments on withCStringLen/peekCStringLen
To: Duncan Coutts [EMAIL PROTECTED]


On 04/06/07, Duncan Coutts [EMAIL PROTECTED] wrote:


Are you sure fromUTF8Ptr is strict in its ptr arg? Try with a ! pattern
on that arg. You'll need -fbang-patterns.


Is there some semantic advantage to bang-patterns, or is it just a
syntactic convenience? 'cause once the guard is in there, it's not
much bother to maintain.



You can also get ghc to tell you what strictness it inferred for your
functions. It's shown in the .hi file. Use ghc --show-iface UTF8.hi.


I tried -ddump-hi and got:

$wfromUTF8Ptr :: base:GHC.Prim.Int#
- base:GHC.Ptr.Ptr base:GHC.Word.Word8
- base:GHC.Base.String
- base:GHC.Prim.State# base:GHC.Prim.RealWorld
- (# base:GHC.Prim.State# base:GHC.Prim.RealWorld,
base:GHC.Base.String #)
 {- Arity: 4 Strictness: LSSL -}

Assuming the LSSL tokens are in the same order as the function
arguments, the first argument is lazy - GHC.Prim.Int#. hmmm some
cognitive dissonance here.

I'm a bit puzzled as to why it's in the .hi file at all - it's not an
exported function.

(I also see quite a bit of code in the hi-dump. Presumably this
permits cross-module inlining, for those selected functions?)

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


[Haskell-cafe] How to read -ddump-hi output (and other phases) from GHC

2007-06-04 Thread Alistair Bayley

I'm collecting links to documents describing some of GHC's
optimisation output flags, like -ddump-hi and -ddump-simpl. I'll add
stuff to this wiki page:
 http://www.haskell.org/haskellwiki/Performance/GHC

So far I've found little bits in the GHC manual, like:

4.16.3. How to read Core syntax
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html#id3130643

(and the Encoding module has the actual rules for the Unique names)
http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs

6.2. Faster: producing a program that runs quicker
http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html
(see How do I find out a function's strictness?)

Any other hints?

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


[Haskell-cafe] Optimising UTF8-CString - String marshaling, plus comments on withCStringLen/peekCStringLen

2007-05-23 Thread Alistair Bayley

Hello cafe,

D'ya fancy an optimisation exercise?

In Takusen we currently marshal UTF8-encoded CStrings by first turning the
CString into [word8], and then running this through a [Word8] - String
UTF8 decoder. We thought it would be more space-efficient (and hopefully
faster) to marshal directly from the CString buffer, rather than use
an intermediate list. We assumed it would be most space-efficient by
working backwards from the end of the CString buffer, like the
peekArray/peekArray0 functions in Foreign.Marshal.Array.

So I implemented it and benchmarked against the original UTF8 marshaling
function, which simply converts CString - [Word] - String.
And to my surprise, the [Word8] - String solution seems to be faster,
and uses less memory, than the function which creates the String directly
from the CString buffer.

Now I appreciate that GHC's optimisations are quite effective (presumably
deforestation should take credit here), but I thought I'd ask the
haskell-cafe optimiser if we could do better with the direct-from-buffer
function. I'm loath to start eyeballing GHC Core, but if needs must...

The code is attached.


I also have some comments/questions about the various CStringLen functions
in Foreign.C.String. The Haddock comment for CStringLen states:
A string with explicit length information in bytes...
and for CWString something similar:
A wide character string with explicit length information in bytes...

I know this is a blatant lie, though, because the code (unless I've grossly
misunderstood it) for newCStringLen, withStringLen, newCWStringLen, and
withCWStringLen all return the number of Haskell Chars in the String
i.e. the number of Unicode chars, NOT the number of bytes.

However, for the sake of inconsistency, the peekC{W}StringLen functions
take, respectively, the number of Word8 or Word16/Word32 elements (whether
CWString is Word16 or Word32 depends on your plaform, apparently) in the
C{W}String array/buffer. So the outputs from newCStringLen etc are not
reliably usable as inputs to their duals (peekCStringLen etc.) The only
cases that they do work in this way is where the CStrings are encoded with
fixed-width encodings i.e. there are no surrogate units in the encoding.

So we have three different approaches:
1. Haddock comments say bytes
2. with/newC{W}StringLen returns unicode char count
3. peekC{W}StringLen expects Word8 or Word16 count

(1) and (3) can be considered equivalent, in the sense that if you know the
number of Word16 units then you know the number of Word8 units, and vice versa.

It'd be nice if we could have one consistent aproach. For a start, I think
we should eliminate (2), because it's dead easy the get the number of
unicode chars from a String (length, if you didn't know). So whether to
settle on (1) or (3) depends on what the most likely use case is for the
length information. Presumably it's going to be passed to a foreign
function which expects the length either in bytes or in Word16/Word32
units. Does anyone have any evidence or opinion as to which case is the
most common: bytes, or encoding units?

Alistair

-- |
-- Module  :  Foreign.C.UTF8
-- Copyright   :  (c) 2004 John Meacham, Alistair Bayley
-- License :  BSD-style
-- Maintainer  :  [EMAIL PROTECTED]
-- Stability   :  experimental
-- Portability :  portable
--
-- Marshall Haskell Strings to and from UTF8-encoded CStrings.
-- This module's code is inspired by John Meacham's UTF8 en-  de-coders,
-- and also those found in the HXT library (module Text.XML.HXT.DOM.Unicode).
-- 
-- Note that the -Len functions all return the length in bytes,
-- not Chars (this is more useful, as you are most likely to want
-- to pass the length to an FFI function, which is most likely
-- expecting the length in bytes). If you want the length in Chars,
-- well, you have the original String, so...


module Foreign.C.UTF8
  ( peekUTF8String, peekUTF8StringLen
  , peekUTF8StringB, peekUTF8StringLenB
  , newUTF8String, withUTF8String, withUTF8StringLen
  , toUTF8String, fromUTF8String
  , lengthUTF8, fromUTF8, toUTF8
  ) where

import Control.Monad (when)
import Data.Bits
import Data.Char
import Data.Word (Word8)
import Foreign.C.Types
import Foreign.C.String
import Foreign.Ptr
import Foreign.Marshal.Array
import Foreign.Storable

nullCChar :: CChar
nullCChar = 0

nullByte :: Word8
nullByte = 0

-- | Analogous to peekCString. Converts UTF8 CString to String.
peekUTF8String :: CString - IO String
peekUTF8String cs = peekArray0 nullByte (castPtr cs) = return . fromUTF8

peekUTF8StringB :: CString - IO String
peekUTF8StringB cs = fromUTF8Ptr0 (castPtr cs)

-- | Analogous to peekCStringLen. Converts UTF8 CString to String.
-- The resulting String will end either when @len@ bytes
-- have been converted, or when a NULL is found.
peekUTF8StringLen :: CStringLen - IO String
peekUTF8StringLen (cs, len) = peekArray len (castPtr cs) = return . fromUTF8

peekUTF8StringLenB :: CStringLen - IO String
peekUTF8StringLenB (cs, len

Re: [Haskell-cafe] flip fix and iterate (was: Lazy IO and closing of file handles)

2007-03-20 Thread Alistair Bayley

On 20/03/07, Bryan Burgers [EMAIL PROTECTED] wrote:

On the topic of 'fix', is there any good tutorial for fix?


I quite liked this one:
 http://dreamsongs.org/Files/WhyOfY.pdf

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


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

2007-03-09 Thread Alistair Bayley

Does anyone have hs-plugins working on WinXP with ghc-6.6? When I run
the simple test below I get this error:

Main:
c:/ghc/ghc-6.6/HSbase.o: unknown symbol `_free'
Main: user error (Dynamic loader returned: user error (resolvedObjs failed.))

Am I doing something obviously dumb?

Alistair


module Test1 where
test1 = putStrLn test1


module Main where
import Prelude hiding (catch)
import Control.Exception
import Data.List
import System.Environment
import System.Plugins

instance Show (LoadStatus a) where
 show (LoadFailure errors) = LoadFailure -  ++ (concat (intersperse
\n errors))
 show (LoadSuccess m p) = LoadSuccess

main = do
 a - getArgs
 let
   modName = case a of
 (n:_) - n
 _ - Test1
 let modPath = ./ ++ modName ++ .o
 let method = test1
 fc - catch (load modPath [] [] method)
   (\e - return (LoadFailure
 [Dynamic loader returned:  ++ show e]))
 case fc of
   LoadFailure errors - do
 fail (concat (intersperse \n errors))
   LoadSuccess modul proc - do
 let p :: IO (); p = proc
 proc
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2007-03-09 Thread Alistair Bayley

Is this using the darcs repository version of hs-plugins?
That's the only versions that works with 6.6


Just got, built, and installed the repo version, and it has the same problem.

Alistair
___
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-09 Thread Alistair Bayley

You managed to build the darcs version under ghc 6.6?

For me runghc setup.hs configure fails
with lots of strange error messages... (below)
other packages build ok.

Rene.

C:\repos\hs-pluginsdarcs pull
plink: unknown option -O
Pulling from http://www.cse.unsw.edu.au/~dons/code/hs-plugins;...
No remote changes to pull in!

C:\repos\hs-pluginsrunghc Setup.lhs configure


I used an MSYS shell on Windows. It doesn't build with ghc/cabal on a
basic windows box - you need some sort of Unix clone. Looks like
you're using cygwin, I think ('cause you still have paths starting
with C:\).

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


Debugging concurrent program - no threads apparently running, but RTS still doing something.

2007-02-22 Thread Alistair Bayley

Below is a test case for a threading problem I can't figure out. It
models a socket server (here I've replaced the socket with an MVar, to
keep it simple). The idea is to have a listener which accepts incoming
requests on the socket. When one arrives, it forks a handler thread to
deal with the request, and returns to listening on the socket.

The handler thread is run in parallel with a timeout thread. In the
test case below, the handler takes too long, so the timeout thread
completes and kills the handler.

The problem is that when the main thread ends, the RTS doesn't stop
for another 6 or so seconds. The only thread that runs this long is
the handler (waitFor (secs 8.0)) but it has already been killed. So
I'm scratching my head a bit.

Also, any pointers to better techniques for designing and debugging
concurrent code are appreciated (is there a better way than putStrLn?)

Platform: ghc-6.6, Windows XP.

Thanks,
Alistair

-

module Main where

import Prelude hiding (catch)
import Control.Concurrent
import Control.Exception
import System.IO

secs :: Float - Int
secs n = round (n * 100)
-- e.g. waitFor (secs 25)
waitFor n =
 debug (waitFor start  ++ show ((fromIntegral n) / 100.0))
  threadDelay n
  debug (waitFor end  ++ show ((fromIntegral n) / 100.0))
debug msg = myThreadId = ( \t - putStrLn $ (show t) ++ :  ++ msg )

-- Thread 1 - start server then send message
main = do
 hSetBuffering stdout LineBuffering
 blockingInput - newEmptyMVar  -- like a socket; accept on a socket blocks
 listnr - forkIO (listener blockingInput)
 putMVar blockingInput hello
 waitFor (secs 2.0)
 debug main: done

-- Thread 2 - listener.
-- Blocks on input; when input arrives, starts handler thread.
listener blockingInput = do
 msg - takeMVar blockingInput
 serveRequest msg
 -- in a real server we'd loop:
 --listener blockingInput
 debug listener: done

-- Start threads 3 and 4 - handler and timeout.
serveRequest msg = do
 let acquire = return ()
 let release _ = debug handler release action
 forkIO (runTimeout 0.1 acquire release (handler msg))
 return ()

handler msg _ = do
 debug (handler start:  ++ msg)
 catch
   (waitFor (secs 8.0)  debug handler end)
   (\e - debug (Exception:  ++ (show e))  throwIO e)

runTimeout timeout acquire release action = do
 handlerTid - myThreadId
 -- Use this to ensure the timeout thread doesn't start before the handler
 -- i.e. give the handler a chance to start.
 startTimeout - newEmptyMVar
 timeoutTid - forkIO (runTimeoutThread startTimeout timeout handlerTid)
 bracket acquire
   ( \a - release a  killThread timeoutTid )
   ( \a - do
 debug runTimeout: start handler action
 putMVar startTimeout True
 action a
 debug runTimeout: end handler action
   )

runTimeoutThread startTimeout timeout handlerTid = do
 takeMVar startTimeout
 debug runTimeoutThread: start
 waitFor (secs timeout)
 killThread handlerTid
 debug runTimeoutThread: end
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Debugging concurrent program - no threads apparently running, but RTS still doing something.

2007-02-22 Thread Alistair Bayley

 The problem is that when the main thread ends, the RTS doesn't stop
 for another 6 or so seconds. The only thread that runs this long is
 the handler (waitFor (secs 8.0)) but it has already been killed. So
 I'm scratching my head a bit.

Short answer: use -threaded.

The runtime is waiting for a worker thread to complete before it can exit; even
though your Haskell thread has been killed, there is still an OS thread
executing Sleep() which was started by threadDelay, and this OS thread has to
complete before the RTS can exit.  We should really terminate the thread more
eagerly, but since this only affects the non-threaded RTS fixing it isn't a high
priority.



Sweet, thanks. A note in the docs somewhere about this implementation
detail would be nice; something that says you may want to consider
-threaded because the implementation of threadDelay uses an OS thread.
I suppose the best place would be in the docs for
Control.Concurrent.threadDelay, although perhaps too a mention in
section 4.10.7 of the ghc user's guide, because in there it says:
Note that you do not need -threaded in order to use concurrency; ...

It could say
Note that you do not need -threaded in order to use concurrency
(unless you use threadDelay - see Control.Concurrent for details);
...

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


[Haskell-cafe] Re: Debugging concurrent program - no threads apparently running, but RTS still doing something.

2007-02-22 Thread Alistair Bayley

 The problem is that when the main thread ends, the RTS doesn't stop
 for another 6 or so seconds. The only thread that runs this long is
 the handler (waitFor (secs 8.0)) but it has already been killed. So
 I'm scratching my head a bit.

Short answer: use -threaded.

The runtime is waiting for a worker thread to complete before it can exit; even
though your Haskell thread has been killed, there is still an OS thread
executing Sleep() which was started by threadDelay, and this OS thread has to
complete before the RTS can exit.  We should really terminate the thread more
eagerly, but since this only affects the non-threaded RTS fixing it isn't a high
priority.



Sweet, thanks. A note in the docs somewhere about this implementation
detail would be nice; something that says you may want to consider
-threaded because the implementation of threadDelay uses an OS thread.
I suppose the best place would be in the docs for
Control.Concurrent.threadDelay, although perhaps too a mention in
section 4.10.7 of the ghc user's guide, because in there it says:
Note that you do not need -threaded in order to use concurrency; ...

It could say
Note that you do not need -threaded in order to use concurrency
(unless you use threadDelay - see Control.Concurrent for details);
...

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


Re: [Haskell-cafe] FFI basics

2007-02-09 Thread Alistair Bayley

I would like to use FFI for the first time. Can someone
give me a really, really simple complete example?

Everything I found on the wiki
seems way beyond that - maybe I missed it.

I am using GHC. I am not using Windows.



From the old wiki:

http://www.haskell.org/hawiki/FfiCookbook
http://www.haskell.org/hawiki/FfiExample
http://www.haskell.org/hawiki/FfiTutorial
http://www.haskell.org/hawiki/FfiWithArrays


From the new wiki, this search shows you pages with titles starting with F:

http://www.haskell.org/haskellwiki/?title=Special%3AAllpagesfrom=fnamespace=0

Is this the stuff you're referring to which seems to be way beyond a
simple example? The FFI tutorial on the old wiki seems to be quite
simple. If you find the pages on the old wiki useful, then please move
them over to the new wiki. Or feel free to write some new pages that
fill the gaps you find.

There's quite a bit of Haskell code about which does FFI. From memory:
darcs, and the various database libs (HSQL, HDBC, Takusen).

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


Re: [Haskell] ANNOUNCE: Data.CompactString 0.1 - my attempt at a Unicode ByteString

2007-02-05 Thread Alistair Bayley

On 05/02/07, Chris Kuklewicz [EMAIL PROTECTED] wrote:

shelarcy wrote:



 Many Hasekll UTF-8 libraries doesn't support over 3 byte encodings.

UTF-8 uses 1,2,3, or 4 bytes.  Anything that does not support 4 bytes does  not
support UTF-8


Well, some of them are probably a bit dated; they likely supported an
older version of the standard.



 But Takusen's implementation support it correctly.

The Takusen does have unreachable dead code to serialize Char as (ord c :: Int)
up to 31 bits into as many as 6 bytes.  But it does decode up to 6 bytes to 31
bits and try to chr this from Int to Char.  Decoding that many bits is not
consistent with the UTF-8 standard.
UTF-8 is a 4 byte encoding.  There is no valid UTF-8 5 or 6 byte encoding.


Chris is right here, in that Takusen's decoder is incorrect w.r.t. the
standard, in allowing up to 6 bytes to encode a single char. If it was
correct, it would reject 5 and 6 byte sequences. I copied the extended
conversion from HXT's code, which was the most correct UTF8 library I
had seen so far (it just didn't marshal directly from a CString, which
was what I was after).

Turns out darcs has the most accurate UTF8 en + de-coders:
 http://abridgegame.org/cgi-bin/darcs.cgi/darcs/UTF8.lhs?c=annotate

There's nothing stopping the Unicode consortium from expanding the
range of codepoints, is there? Or have they said that'll never happen?

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


[Haskell] ANN: Takusen 0.6

2007-02-02 Thread Alistair Bayley

We are pleased to announce a new release of Takusen. There are a large
number of changes and bug-fixes:
- Oracle support for processing cursors returned from procedure calls
- withContinuedSession supports connection reuse (e.g. for persistent
connections and connection pooling)
- new README file with useful information about getting started with Takusen
- new UTF8 en/de-coder (the old one was buggy)
- PostgreSQL support for CalendarTime
- improved Cabal Setup.hs script, which does a better job of
modifying the installation to reflect installed DBMS's. This gives
good ghci support (PostgreSQL users on Windows have a small extra
step)
- prepared statement API requires that users distinguish between
queries and DML

Our long-term plans are the same as ever:
- large objects
- ODBC and MS Sql Server backends


Release:
 http://darcs.haskell.org/takusen/takusen-0.6.tar.gz

Source:
 darcs get --partial http://darcs.haskell.org/takusen


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


[Haskell-cafe] ANN: Takusen 0.6

2007-02-02 Thread Alistair Bayley

We are pleased to announce a new release of Takusen. There are a large
number of changes and bug-fixes:
- Oracle support for processing cursors returned from procedure calls
- withContinuedSession supports connection reuse (e.g. for persistent
connections and connection pooling)
- new README file with useful information about getting started with Takusen
- new UTF8 en/de-coder (the old one was buggy)
- PostgreSQL support for CalendarTime
- improved Cabal Setup.hs script, which does a better job of
modifying the installation to reflect installed DBMS's. This gives
good ghci support (PostgreSQL users on Windows have a small extra
step)
- prepared statement API requires that users distinguish between
queries and DML

Our long-term plans are the same as ever:
- large objects
- ODBC and MS Sql Server backends


Release:
 http://darcs.haskell.org/takusen/takusen-0.6.tar.gz

Source:
 darcs get --partial http://darcs.haskell.org/takusen


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


Re: [Haskell-cafe] Simple HTTP lib for Windows?

2007-01-18 Thread Alistair Bayley

I'd like to write a very simple Haskell script that when given a URL, looks
up the page, and returns a string of HTML. I don't see an HTTP library in
the standard libs, and the one in Hackage requires Windows machines have GHC
and MinGW to be installed and in the PATH.

Is there a simple way to get the contents of a webpage using Haskell on a
Windows box?


This isn't exactly what you want, but it gets you partway there. Not
sure if LineBuffering or NoBuffering is the best option. Line
buffering should be fine for just text output, but if you request a
binary object (like an image) then you have to read exactly the number
of bytes specified, and no more.

Alistair

module Main where

import System.IO
import Network

main = client www.haskell.org 80 /haskellwiki/Haskell

client server port page = do
 h - connectTo server (PortNumber port)
 hSetBuffering h NoBuffering
 putStrLn send request
 hPutStrLn h (GET  ++ page ++ \r)
 hPutStrLn h \r
 hPutStrLn h \r
 putStrLn wait for response
 readResponse h
 putStrLn 

readResponse h = do
 closed - hIsClosed h
 eof - hIsEOF h
 if closed || eof
   then return ()
   else do
 c - hGetChar h
 putChar c
 readResponse h
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] importing Distribution.Compat.FilePath fails

2006-11-19 Thread Alistair Bayley

On 18/11/06, Magnus Therning [EMAIL PROTECTED] wrote:

  Could not find module `Distribution.Compat.FilePath':
it is hidden (in package Cabal-1.1.6)

I want to use 'joinFileName'.


Try upgrading to 1.1.6.1. This explains why:
http://www.haskell.org/pipermail/libraries/2006-October/005996.html

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


Re: Here-docs in Haskell source

2006-09-23 Thread Alistair Bayley

On 22 Sep 2006 23:54:42 -0400, Ian Zimmerman [EMAIL PROTECTED] wrote:


Here's a quick test: put the cursor in front of a triple-quoted string,
then hit Control-Alt-F (forward-sexp).  It should move just after the
whole string.  Does it?

Any tool which assumes strings are delimited by a single front delimiter
and a single end delimiter, which they are in most reasonable languages,
will have trouble.


(just speculating here...)

In order to produce one double-quote inside a double-quote delimited
string, many (most?) languages let you use two adjacent double quotes.
So a string starting with triple double-quote would result in a string
that has one double quote as its first char.

I imagine that smarter language-aware editors would handle this case,
otherwise they would not correctly recognise whether or not the cursor
was inside a string literal.

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


  1   2   >