Re: [Haskell-cafe] Haskell shootout game

2007-07-17 Thread Björn Bringert

Hugh Perkins wrote:

Had an idea: a real shootout game for Haskell.

The way it would work is:
- you email a haskell program to a specific address
- it shows up on a web-page

The webpage shows the last submitted solution for each person
- anyone can select two solutions and click Fight
- the scripts fight in an arena for a second or so, and the results 
are published to the website


...


Something like this was done as a student project at Chalmers a few 
years ago. Unfortunately the web site is gone, but some of it survives 
in the Wayback machine:

http://web.archive.org/web/20040811042735/www.dtek.chalmers.se/~d00nibro/hwars/index.php4?Page=presentation

You can probably find out more if you ask the project members:
http://web.archive.org/web/20040811042126/www.dtek.chalmers.se/~d00nibro/hwars/index.php4?Page=members

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


Re: [Haskell-cafe] ANN: MIME Strike Force

2007-03-19 Thread Björn Bringert

Jeremy Shaw wrote:

Hello,

If you have tried to do any MIME processing using Haskell, you are
likely to have found two things:

 1) There are a lot of MIME libraries for Haskell
 2) None of them do everything you want

So, I propose that we form a MIME Strike Force and create the one,
true MIME library. 


The plan is something like this:

1) Document all the things the MIME library needs to support.

2) Pick the technology, and design the infrastructure for supporting
   these features. For example, I don't think we will be able to use
   Parsec because:

   i) We want to support ByteString
   ii) We want to be able to lazily parse the message

3) Try to reuse as much existing code as possible to implement the
   design.

I have started step 1 by creating this page:

http://www.haskell.org/haskellwiki/Libraries_and_tools/MIMEStrikeForce

Please add your comments, requirements, etc.

If you are interesting in helping contrib ideas, code, or flames,
please let me know. If there is enough interest, we should probably
set up a mailing list for discussion.

j.

ps. This *might* make a decent SoC project, but only if it results in
the one, true MIME library. We definitely do not need another
incomplete MIME library floating around. 


Good idea! I added a subsection for existing code to the wiki page, and 
added the multipart parser from the cgi package, which uses ByteStrings.


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


Re: [Haskell-cafe] Make strict (IO String) lazy

2007-03-15 Thread Björn Bringert

Henning Thielemann wrote:

 On the one hand, in the standard libraries there are functions like
readFile, getContents, hGetContents which read a file lazily. This is
often a nice feature, but sometimes lead to unexpected results, say when
reading a file and overwriting it with modified contents. Unfortunately
the standard libraries provide no functions for strict reading, and one
has to do this manually.
 On the other hand, when I write some IO function that returns a String, I
easily end up with a function which produces the String in a strict way.
(Say I call some shell commands and concatenate their outputs.)
 What is the preferred way to turn a strict (IO String) into a lazy one?
forkIO? forkOS? How would one derive readFile from a hypothetical
strictReadFile?


Perhaps I misunderstood you, but wouldn't using fork* just make it 
nondeterministic, not lazy? unsafeInterleaveIO is the way to go, though 
it won't allow you to write readFile using strictReadFile. Rather, it 
allows you to write readFile using hGetChar. unsafeInterleaveIO . 
strictReadFile is not lazy enough, since it reads the whole file when 
you force the head of the string.


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


Re: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-14 Thread Björn Bringert

Simon Peyton-Jones wrote:

| The error in linux is:
| Illegal instance declaration for `Read (UArray Int Double)'
| (The instance type must be of form (T a b c)
|  where T is not a synonym, and a,b,c are distinct type variables)
| In the instance declaration for `Read (UArray Int Double)'
|
| Why does it want three parameters for the instance type?  I am baffled by
| this.

It's saying that in Haskell 98 you can have
instance Read (UArray a b)
(for type variables a, b) but not
instance Read (UArray Int Double)

(As Spencer says, use -fglasgow-exts to lift the H98 restriction.)

However, you mis-read the error message to say the instance type must have three 
parameters, which isn't what I meant at all!  I was trying to use an example of the 
general form, but conveyed the wrong idea.

I can see why you read it that way.  Now you understand, can you give me a 
better error message?


I'm not the original poster, but what about just changing it to The 
instance type must be of the form (T a1 ... an) where T is not a 
synonym, and a1 ... an are distinct type variables)?


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


Re: [Haskell-cafe] Did quickchekc get dropped from ghc from 6.4 to 6.6?

2007-02-26 Thread Björn Bringert

Thomas Hartman wrote:

According to

http://www.cs.chalmers.se/~rjmh/QuickCheck/

Quickcheck is distributed with ghc.

I seem to recall this came with ghc 6.4. After upgrading to ghc 6.6,
however, I don't seem to have it anymore.

Do I need to install it from cabal? If so, I assume this would start
by wgetting

http://hackage.haskell.org/packages/archive/QuickCheck/QuickCheck-1.0.tar.gz 



and building that.

thomas.


Hi Thomas,

between GHC 6.4 and 6.6 many libraries were moved into the ghc-extralibs 
source tarball. QuickCheck is among those. If you install GHC from the 
source tarball, you may also want to grab extralibs and install that, if 
you want an environment resembling the one you get with a normal GHC 6.4 
installation.


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


Re: [Haskell-cafe] Difference between Lazy ByteStrings and Strings in alex

2007-02-14 Thread Björn Bringert
On a related topic, I think Duncan Coutts and Lennart Kolmodin have 
worked on adding ByteString support to Alex. It seems to be available in 
the current darcs version of Alex. You many want to check with them for 
more details.


/Björn

Jefferson Heard wrote:
It was suggested that I might derive some performance benefit from using lazy 
bytestrings in my tokenizer instead of regular strings.  Here's the code that 
I've tried.  Note that I've hacked the basic wrapper code in the Lazy 
version, so the code should be all but the same.  The only thing I had to do 
out of the ordinary was write my own 'take' function instead of using the 
substring function provided by Data.Lazy.ByteString.Char8.  The take function 
I used was derived from the one GHC uses in GHC.List and produces about the 
same code.  

The non-lazy version runs in 38 seconds on a 211MB file versus the lazy 
versions 41 seconds.  That of course doesn't seem like that much, and in the 
non-lazy case, I have to break the input up into multiple files, whereas I 
don't have to in the lazy version -- this does not take any extra time.  The 
seconds do add up to a couple of hours for me, though once I'm done, and so 
I'd like to understand why, when the consensus was that Data.ByteString.Lazy 
might give me better performance in the end, it doesn't do so here.  

I am running GHC 2.6 now, and am using -O3 as my optimization parameter.  I'm 
profiling the code now, but was wondering if there was any insight...


-- Jeff 


Non-lazy version

{
module Main
where

import qualified FileReader

}

%wrapper basic

$letter = [a-zA-Z]
$digit = 0-9
$alphanum = [a-zA-Z0-9]
$punct = [\! \@ \# \$ \% \^ \ \* \( \) \_ \- \+ \= \{ \[ \} \] \\ \| \; \: \' 
\ \, \. \? \/ \` \~]

$dec = \.
$posneg = [\- \+]

@date1 = jan($punct|uary)?\ $digit{1,2}(\,\ $digit{2,4})?
   | feb($punct|ruary)?\ $digit{1,2}(\,\ $digit{2,4})?
   | mar($punct|ch)?\ $digit{1,2}(\,\ $digit{2,4})?
   | apr($punct|il)?\ $digit{1,2}(\,\ $digit{2,4})?
   | may?\ $digit{1,2}(\,\ $digit{2,4})?
   | jun($punct|e)?\ $digit{1,2}(\,\ $digit{2,4})?
   | jul($punct|y)?\ $digit{1,2}(\,\ $digit{2,4})?
   | aug($punct|ust)?\ $digit{1,2}(\,\ $digit{2,4})?
   | sep($punct|tember)?\ $digit{1,2}(\,\ $digit{2,4})?
   | sept($punct)?\ $digit{1,2}(\,\ $digit{2,4})?
   | oct($punct|ober)?\ $digit{1,2}(\,\ $digit{2,4})?
   | nov($punct|ember)?\ $digit{1,2}(\,\ $digit{2,4})?
   | dec($punct|ember)?\ $digit{1,2}(\,\ $digit{2,4})?

@date2 = $digit{1,2} $punct $digit{1,2} $punct $digit{2,4}

@time = $digit{1,2} \: $digit{2} (am|pm)?

@word = $alphanum+

@number = $posneg? $digit+ 
| $posneg? $digit+ $dec $digit+

| $posneg? $digit+ (\,$digit{3})+
| $posneg? $digit? (\,$digit{3})+ $dec $digit+

$white = [\t\r\n\v\f\ ]

@doc = \ DOC \
@tag = \ $alphanum+ \
 | \\/ $alphanum+ \

tokens :- 
  @doc{ \s -  }

  @tag;
  $white+ ; 
  @time   { \s - s }
  @number { \s - s } 
  @word   { \s - s }
  $punct  ; 
  .   ;


{

printCount c [] = print c
printCount c (l:ls) = if l ==  then printCount (c+1) ls else printCount c ls

main = do
file - readFile trecfile1 
printCount 0 (alexScanTokens file) 
 
}


-- 

Version depending on ByteString.Lazy -- note that the grammar is the same, so 
it has been omitted

-- 


... grammar ...

{
type AlexInput = (Char, -- previous char
  B.ByteString)   -- current input string

takebytes :: Int - B.ByteString - String
takebytes (0) _ =  
takebytes n s = c : takebytes (n-1) cs
where c = B.index s 0
  cs = B.drop 1 s

alexGetChar :: AlexInput - Maybe (Char,AlexInput)
alexGetChar (_, bytestring) 
| bytestring == B.empty = Nothing

| otherwise = Just (c , (c,cs))
where c = B.index bytestring 0
  cs = B.drop 1 bytestring

alexInputPrevChar :: AlexInput - Char
alexInputPrevChar (c,_) = c

alexScanTokens :: B.ByteString - [String]
alexScanTokens str = go ('\n',str)
  where go inp@(_,str) =
  case alexScan inp 0 of
AlexToken inp' len act - act (takebytes len str) : go inp'
AlexSkip  inp' len - go inp'
AlexEOF - []

AlexError _ - error lexical error





printCount :: Int - [String] - IO ()
printCount c [] = print c
printCount c (l:ls) = if l ==  then printCount (c+1) ls else printCount c ls

main = do
file - B.readFile trecfile1 
printCount 0 (alexScanTokens file) 
 
}

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


___
Haskell-Cafe mailing list

Re: [Haskell-cafe] Re: Network.CGI.Compat.pwrapper

2007-02-14 Thread Björn Bringert

Gracjan Polak wrote:

Bjorn Bringert bringert at cs.chalmers.se writes:

Is there a description what is a *CGI* protocol?

Here you go: http://hoohoo.ncsa.uiuc.edu/cgi/interface.html



I should be more clear: what kind of data does pwrapper expect? Somewhere in the
middle it needs two handles: one to write and one to read which seem to be
equivalent to stdin/stdout. But what about environment? How is it transfered, as
someone ale pointed out pwrapper runs on different machine?


I think your best bet is to read the code, it's not many lines. IIRC, 
pwrapper takes the environment variables from the local environment, 
which is rather useless. If you want a protocol for talking CGI over a 
socket, FastCGI does just that.


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


Re: [Haskell-cafe] Calendar Dates before the epoch

2007-02-13 Thread Björn Bringert

jim burton wrote:

It seems that CalendarTime is for dates since the epoch...what do I use to
handle dates before that? Sorry if this is an FAQ, I looked on the wiki and
tried to find MissingH since I thought it might be in there, but don't know
where to find it. I also found this from 2003 -
http://www.arcknowledge.com/gmane.comp.lang.haskell.libraries/2003-11/msg00019.html
- is the code in a library somewhere?

Thanks.


Use the time package (Data.Time.*). time-1.0 is in GHC 6.6 extralibs, 
and available from Hackage 
(http://hackage.haskell.org/cgi-bin/hackage-scripts/package/time-1.0) 
and the development version lives at http://darcs.haskell.org/packages/time/


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


Re: [Haskell-cafe] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)

2007-02-05 Thread Björn Bringert

Thomas Hartman wrote:

haskellers, I'm contemplating returning to school after a decade as a
worker bee, and almost that long as a worker bee doing computer
consulting / miscelaneous tech stuff.

Ideally I'd like to get a masters, but I don't know if that's feasible
this late in the game. If it's not, I might settle for a lesser degree
and worry about the masters later.

Part of my desire to return to school is that after encountering
functional programming over the past year or so (first through lisp,
then haskell), I've found something that I'm really interested in, but
that it feels the amount of learning I can do around a job just won't
cut it to get to the level that I want. That's the personal reason;
the practical reason is that I think it would be a good networking
opportunity (hankering to start my own company, and not meeting the
right kinds of people), and obviously increase my chance of getting
better paying, but especially more *interesting* jobs. I have some
savings, figure loans would cover the rest, and no wife or kids.

So I'll make a rather open ended request for advice. Are there decent
comp sci master's programs out there that will take someone who didn't
do a hard science in undergrad, but has lots of work-related
experience with programming? If not, what's the next best thing? Get a
quick bachelor's? Spend six months cramming for the GREs and then try
for a master's?

Whether master's, bachelor's, or other, I am specifically interested
in programs that are functional friendly. In other words, I don't
want to just go and study algorithms in java for two years. Ideally,
I'd like to go somewhere where I could really explore and get good at
the functional languages, with haskell my current favorite but also
open to others. (For what it's worth, most of my experience is in
perl, but I take it seriously as a language and try not to write the
kind of throwaway crap that mean people make fun of.)

My background is that I have a liberal arts bachelors from an american
ivy. Though I enjoyed the program very much, it probably wasn't the
wisest financial decision, given the type of career I subsequently
gravitated to. But hey, maybe that gives me a different kind of
perspective that has its own kind of value. Since, then, there;s
mainly work work work for me, with some time off bumming around
europe. And, on my own time: learn learn learn. I'm now 31.

I've been living in germany for a few years, mainly freelancing as a
computer consultant, and am open to programs in europe -- probably
either england or germany. Largely because programs out here seem to
be significantly cheaper than programs in the states, and being a
somewhat older student seems to be less unusual out here. However,
truth be told, I have a hankering for my homeland, the good old USA.
And if possible somewhere in california, where my extended family is
based, or it not that new york, where I have a good network. (But open
to other locations as well; cali and new york would just be my top
choices.)

Distance learning is okay if the program is really good, but doing the
campus thing again, perhaps while working part or semi-full time,
would be the ideal (though perhaps I'm pushing the age limit there?).

This has gotten rather long, so I'll leave it at that.

Sorry about going off topic, and thanks in advance for any advice.


Hi Thomas,

the Computer Science Master's programs at Chalmers  Göteborg University 
(Sweden) are quite functional friendly. Courses in functional 
programming (Haskell) are mandatory for most students, and in many other 
courses students are encouraged to use Haskell.


The Göteborg University version of the Master's program [1] still 
accepts applications for this fall (until Feb 15). The possible 
specializations correspond to the Chalmers Master's programs [2].
The Master's program seems to require a Bachelor's degree in Computer 
Science or equivalent, so I don't know how that would work out in your 
case. The courses are held in English, and as far as I understand, 
tuition in Sweden is free to everyone, regardless of citizenship.


Disclaimer: I'm a PhD student at the Chalmers  GU CSE department.

/Björn

[1] 
http://www.ituniv.se/w/index.php?option=contenttask=viewid=1486Itemid=173eduPage=programinl.phpprgm=cs

[2]
http://www.chalmers.se/cse/EN/education/masters-programmes
___
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-19 Thread Björn Bringert

Greg Fitzgerald wrote:
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?


I agree with other posters that the Network.HTTP API should be made more 
easy to use. I will happily accept patches for this.


The HTTP package homepage (http://www.haskell.org/http/) mentioned the 
GHC and MinGW requirements you cite, but those seemed to be out of date. 
You should be able to use plain Cabal to install the HTTP package for 
any recent GHC or Hugs.


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


Re: [Haskell-cafe] question about database interfaces

2007-01-09 Thread Björn Bringert

Eric Sessoms wrote:

Hi All,

I've found the list of database libraries at
http://www.haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces
but I haven't found much guidance in choosing among them.
, which is what most people are
So I'm wondering -- in practice, what do people actually use?  Is
there a more-or-less generally accepted standard database library for
Haskell?


No, there isn't an accepted standard. For low-level database access 
(read: using SQL strings), HDBC, HSQL and Takusen are the currently 
useful libraries as far as I know.


There is also HaskellDB, which attempts to free you from writing SQL and 
instead present a high-level, type-safe back-end independent interface.


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


Re: [Haskell-cafe] deepSeq vs rnf

2006-11-13 Thread Björn Bringert

Cale Gibbard wrote:

On 22/10/06, Chad Scherrer [EMAIL PROTECTED] wrote:

Hi,

I had posted this question a while back, but I think it was in the
middle of another discussion, and I never did get a reply. Do we
really need both Control.Parallel.Strategies.rnf and deepSeq? Should
we not always have

x `deepSeq` y == rnf x `seq` y
?

Maybe there's a distinction I'm missing, but it seems to me they're
basically the same.


I agree, they are the same. The Strategies library also gives much
more general operations for working with strictness and
parallelisation. That library seems to need more love, I think it's a
great idea, but it doesn't really get noticed all that much. The
Hierarchical libraries documentation for it is a little lacking -- it
doesn't even provide a reference or link to the paper, and many of the
combinators, as well as the general idea of how to use it are
undocumented from there. It also spuriously contains an Assoc
datatype, which if I recall correctly, was an example from the paper,
but doesn't really belong in the library as far as I can tell. It
would also be really nice to see the list of instances for the NFData
class expanded to include other datatypes in the libraries, possibly
also with compiler support for deriving, since it's mostly
boilerplate.


I wanted to use the Strategies library and didn't understand much of it, 
so I sat down and documented it. The darcs version, 
http://darcs.haskell.org/packages/base/Control/Parallel/Strategies.hs 
has my changes.


If noone objects, I could do some more clean-up, including:

- Add NFData instances for common data types, such as
  - Maybe
  - Either
  - Data.Map.Map
  - Data.Set.Set
  - Data.Tree.Tree
  - All Data.Int and Data.Word types

- Deprecate sSeq and sPar, as the code comments say that you should use
  demanding and sparking instead.

- Deprecate these defintions, which seem to be examples or
  Lolita-specific:
  - Assoc
  - fstPairFstList
  - force
  - sforce


If anyone has objections or further suggestions, let me know.

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


Re: [Haskell-cafe] string to date?

2006-11-09 Thread Björn Bringert

Dougal Stanton wrote:

Quoth Magnus Therning, nevermore,

I've been staring my eyes out trying to find a function that converts a
string into a ClockTime or CalendarTime.  Basically something like C's
strptime(3).  I can't seem to find anything like it in System.Time,
there are function that convert _to_ a string, but nothing that converts
_from_ a string it seems.  Where should I look?


The MissingH.Time.ParseDate [1] module might be what you want. There's
also one from Bjorn Bringert [2]. I haven't used either though, so I
can't recommend anything between them.

Cheers,

D.

[1]: http://quux.org:70/devel/missingh/html/MissingH-Time-ParseDate.html
[2]: http://www.cs.chalmers.se/~bringert/darcs/parsedate/


Those two are the same code. I have a preliminary new version which can 
also parse most of the types from the time package (Data.Time.*) 
available at:


http://www.cs.chalmers.se/~bringert/darcs/parsedate-2/

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


Re: [Haskell-cafe] Substitute for records?

2006-04-10 Thread Björn Bringert

Mattias Bengtsson wrote:

Currently i'm working, together with a friend, on an abstraction (sort
of) of HaskellDB for a school-project.
Basically we are generating haskell-modules similar to those generated
by DBDirect in HaskellDB together with some helpers for the most common
queries you'd want to run.
HaskellDB has its own record system (HDBRec) and a HaskellDB-query also
returns such a record. The accessor-functions for these records can
later be found in DatabaseName.TableName.ColumnName.column. These should
be imported qualified to avoid name clashes.
This is some example code:

  students - School.Students.all db
  mapM_ printStudentId students

  printStudentId rec = print $ rec!School.Students.Id.column

The main problem for me here is this part:
  rec!School.Students.Name.column
where i would rather just write 
  rec!id 
This isn't possible and the other way is just too messy for my taste. It

simply isn't the easy and nice syntax i had hoped for when we started to
develop this.
Are there any other nice substitutes for HDBRec or normal haskell
records that i could use that doesn't make name clashes an issue?

Mattias


It's not perfect, but you can make it a lot shorter by importing the 
modules that declare the fields with shorter names:


  import qualified School.Students as Students
  import qualified School.Students.Name as Name

  students - Students.all db
  mapM_ printStudentId students

  printStudentId rec = print $ rec!Name.column

But the right answer, I'm afraid, is that there is no really nice way to 
work with records in today's Haskell.


You may want to have a look at HList [1] to see if that works better. If 
it does, you are very welcome to port HaskellDB to use it instead of HDBRec.


/Björn

[1] http://homepages.cwi.nl/~ralf/HList/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] PPM image manipulation

2006-04-05 Thread Björn Bringert

Jared Updike wrote:

...
P.S. After googling around for haskell image manipulation (in the
hopes of finding some Haskell image lib like VIPS [1] or the Python
Imaging Library [2]), I found the assignment spoken of
  http://cs.anu.edu.au/Student/comp1100/assts/asst1/
just so everyone knows. BTW, does Haskell have an imaging library that
people usually turn to? (Or should I add that to my list of cool
projects that I need to get around to ...)


There are a bunch of libraries listed on the wiki [1], but I don't know 
if there is one that poeple usually turn to. I rolled my own GD binding 
[2] when I needed to resize JPEGs, but that's all it does at the moment. 
Contributions are welcome.


/Björn

[1]
http://www.haskell.org/haskellwiki/Libraries_and_tools/Graphics

[2]
http://www.cs.chalmers.se/~bringert/darcs/haskell-gd/doc/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] hs-plugins/ haskelldb/ ELF zlib incompatibility.

2006-03-20 Thread Björn Bringert

Marc Weber wrote:

I get this error:

calhost db=store uid=marc pwd= DB/Direct: Daan Leijen (c) 1999, HWT
(c) 2003-2004, Bjorn Bringert (c) 2005

Connecting to database... DBDirect: user error (loadShared: couldn't
load `/usr/lib/libz.so' because /usr/lib/libz.so: invalid ELF header

Any idea how to fix it ? (What to watch for?)

latest cvs ghc, latest darcs hs-plugins (dons told me to ask the 
haskelldb how they managed to run it..) I've tried compiling with -lz

option. Same result. I'm also posting here because I don't know how
frequently the haskelldb mailinglist is read yet.. It doesn't seem to
be used by that much people yet.


I don't think that this is HaskellDB specific, so I'll post my reply
here as well (this is the same as my reply to you post to haskelldb-users):

I once ran into a similar problem in ghci when I had an unneccessary
-lc in the package configuration, and my libc.so was a linker script.
I'm guessing that this is the same problem, since DBDirect uses
hs-plugins to load a module which requires libz. Maybe you could try 
loading the HSQL MySQL module into ghci and see if you get the same 
problem. If you do, you could try to remove libz from the 
extra-libraries list in the package configuration for hsql-mysql.


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


Re: [Haskell-cafe] Web application frameworks

2006-03-07 Thread Björn Bringert

Graham Klyne wrote:

[Switching to haskell-cafe]
Niklas Broberg wrote:



...



On 3/6/06, Graham Klyne [EMAIL PROTECTED] wrote:

- Options to run the whole thing behind Apache to leverage its security and web
space management capabilities


Lemmih has implemented a HSP/FastCGI binding for Apache. I also know
that work is being done on building a direct HSP/Apache binding. All
work in progress though.


Yes, I was aware of a fastCGI for Haskell.  Didn't Bjorn Bringert (also)
implement one?  I tend to think of CGI programs as run-to-completion-then-exit,
even when a fastCGI interface allows a persistent wrapper program to speed
startup.  But I could easily be missing something here.


Yes, I have written a FastCGI binding (darcs repo here: 
http://www.cs.chalmers.se/~bringert/darcs/haskell-fastcgi/). If I'm not 
mistaken, that's what Lemmih is using for his HSP/FastCGI binding.


I have only used FastCGI the way you describe, as CGI without start-up 
penalty, though I can't see why you couldn't keep some state between 
requests to a FastCGI application. I believe that Ruby-on-Rails (which 
I've never used, so I'm not too sure) can use FastCGI.


One problem with Apache and FastCGI is that the Apache FastCGI module 
doesn't seem to support concurrent requests to a single FastCGI process 
(even though the FastCGI protocol allows this). This means that Apache 
will have to run several instances of the Haskell-over-FastCGI app to 
serve concurrent requests, or be forced to serialize the requests. 
Having several instances of course means that you can't really keep 
stuff like session data in memory in the FastCGI process. If the Apache 
module supported concurrent requests we could spawn a new Haskell thread 
to serve each request, which ought to scale well.



...


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


Re: [Haskell-cafe] Printing functions

2006-01-25 Thread Björn Bringert

Creighton Hogg wrote:

Hi,
I'm working on writing a genetic programming system in 
Haskell, and I wanted to know what might be a good way to 
print out the programs that are being generated.
There's no instance of Show for functions, but I'd really 
like to see what's happening so that I know if it's working 
right.

What should I try?


One way would be to, instead of generating Haskell functions directly (I 
guess this is what you are doing), declare an algebraic data type with 
constructors for the various basic functions that you use (again I'm 
guessing as to how you are doing this). Then you can have a Show 
instance for that type, and a function for producing a real function 
from a value of your type.


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


Re: [Haskell-cafe] Re: Can I use Haskell for web programming

2006-01-23 Thread Björn Bringert
I think the easiest way to achieve that would be to do as Thomas Davie 
suggested earlier and get a virtual server where you can install 
whatever you want.


/Björn

Maurício wrote:
  I think it would be interesting to ask some professional site to 
install hsp, before I go to the cgi solution. If I want to do that, what 
should I ask them to install to get a full working environment, with 
access to SQL and other stuff?


  Maurício

Niklas Broberg wrote:


hsp can be run in two different modes. Running the full-blown version
with runtime system will probably be hard on a professional site, you
would have to convince them to install hsp. But if you can do without
the fancier bits, in particular application-scoped data, you can run
hsp pages as ordinary cgi scripts. Look in the HSPR.CGI.RunCGI module.

/Niklas

On 1/21/06, Maurício [EMAIL PROTECTED] wrote:


  They both look cool. Do you think I'll be able to find someone to
host professional sites using those libraries?

  [],
  Maurício

Sebastian Sylvan wrote:


On 1/21/06, Maurício [EMAIL PROTECTED] wrote:



 Hi,

 Can I use Haskell to do what people do with, say, PHP? More and more
I have the need for that, and I've been looking into Ruby on Rails. Do
you thing Haskell could be a choice? Of course, I don't need something
exactly like PHP (for instance, I don't care if I can't insert code in
the middle of xhtml pages. If I have to generate everything from 
Haskell

code, I would probably like it. Also, CGI can be a choice). But I need
reasonable efficiency and to be able to find someone to host my site.
 What solutions do you suggest me?




Take a look at WASH and HSP...

http://www.informatik.uni-freiburg.de/~thiemann/WASH/
http://www.cs.chalmers.se/~d00nibro/hsp/

--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862



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



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


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


Re: [Haskell-cafe] RE: [Haskell] Haskell DB bindings (was Re: ANN: HDBC (HaskellDatabase Connectivity)

2006-01-10 Thread Björn Bringert

Bayley, Alistair wrote:

[Moving to café, too]



There are three active database libraries: HDBC, HSQL and Takusen.
It is quite disappointing from my point of view. Recently there was
the same situation with the GUI libraires. The Haskell Community is
quite small to waste efforts, developing different libraries for
the same things. When I started with HSQL there were only two
database libraries: HaSQL for ODBC and libpq for PostgreSQL. They
both are dead, I think. I decided that it is useful to have one
abstract API that can cover all database bindings. I imagine
something like JDBC, ADO or DBI for Haskell. If you guys would like
this to happen then lets discuss what we want. I would be happy to
work on single project that can satisfy all needs.

Cheers, Krasimir





... The Haskell Community is quite small to waste efforts,
developing different libraries for the same things.



Yes, that could be considered undesirable. However, there is the
choice for users over which API to choose that best supports their
needs. In the use of an enumerator, Takusen has chosen quite a
different design space from HSQL and HDBC. Whether or not that proves
to be a good idea, or attractive to users, remains to be seen :-)

HaskellDB+HSQL seems to be to be the most mature, and actively
maintained. Although I'm keen to progress Takusen, I find it hard at
present to take the necessary time, so work seems to stall. I'd have
no bone to pick with HaskellDB+HSQL being promoted as the default
database API, but I still want to work on Takusen, because I think
there are some ideas worth exploring.

When I started Takusen, I was specifically interested in using
HaskellDB to interface to Oracle. At the time, HaskellDB did not use
HSQL, and HSQL lacked a unifying interface, so I started work on a
low-level library to Oracle (I was also keen to learn to use the
FFI). The design later evolved towards the enumerator approach (Oleg
persuaded me that it was a good idea) and the HaskellDB goal was
never reached. Now that HSQL supports Oracle, I can choose to use
HaskellDB with Oracle, so I suppose my original goal has been
satisfied.


Just for the record, the current darcs version of HaskellDB [1] works 
with both HSQL and HDBC.


/Björn

[1] darcs get --partial http://cvs.haskell.org/darcs/haskelldb/

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


Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Björn Bringert

Creighton Hogg wrote:

Hi,
so I'm a newbie getting used to Haskell.  I'm writing some 
simple things like genetic algorithms in it for practice, 
and I keep coming across something that really bugs me:  
are there any standard libraries that allow you to 
do imperative style for or while loops using monads to keep 
track of state?


I know there's things like until, but honestly that's not 
quite what I'm looking for.  

I just think there should be a simple way to say execute 
this block of code 10 times without having to wrap it up in 
recursion.  

Haskell seems to me to be a very powerful language, and it 
looks like it should be possible to define control 
structures such as for loops using monads.


Could Control.Monad.replicateM or Control.Monad.replicateM_ be what you 
are looking for?


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