Re: [Haskell-cafe] SQL Database in Haskell?

2009-08-05 Thread Mattias Bengtsson
On Thu, 2009-08-06 at 00:04 +0200, Günther Schmidt wrote:
 Hi Don,
 
 I actually meant an SQL database written in Haskell, same as Derby or  
 HSQLDB in Java.
 
 I'm currently using Sqlite3 with HDBC but would prefer one entirely in  
 Haskell (but still SQL though, because of persistence and performance).

SQL is just a query language and the use of it is, as far as i can tell,
orthogonal to the need for persistence and performance. 

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


Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-07-06 Thread Mattias Bengtsson
On Sun, 2009-07-05 at 22:30 +0200, Henning Thielemann wrote:
 
 (?) is also undefined in Prelude.

Which i think is a good thing. 
I think it's quite nice to use (?) as an operator in higher order
functions. 
Eg. 
foldr _ z [] =  z
foldr (?) z (x:xs) =  x ? foldr (?) z xs

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


Re: [Haskell-cafe] HaRe (the Haskell Refactorer) in action - short screencast

2009-06-23 Thread Mattias Bengtsson
On Tue, 2009-06-23 at 00:02 +0100, Claus Reinke wrote:
 [...] With the recent interest in screencasts, I thought I'd make a little
 demo, for archival purposes. [...]

Impressive!

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


Re: [Haskell-cafe] Combine to List to a new List

2009-06-09 Thread Mattias Bengtsson
On Tue, 2009-06-09 at 06:05 -0700, ptrash wrote:
 Hi,
 
 I have the following two lists:
 
 a = [1,2,3]
 b = [A,B,C]
 
 I want a combination of the to lists:
 
 c = [(1,A), (2, B), (3, C)]
 
 How can I do this?

What you want is a function with the following type signature:
[t1] - [t2] - [(t1,t2)]

Search for that in hoogle[1] and you get the function zip as a
result[2] (as already told in this thread).
Hoogle is your friend (and helps you help yourself)! :)

1: http://haskell.org/hoogle/
2: http://haskell.org/hoogle/?hoogle=%5Ba%5D+-%3E+%5Bb%5D+-%3E+%5B%28a%
2Cb%29%5D

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


Re: [Haskell-cafe] Facebook puzzles allow for GHC solutions

2009-05-27 Thread Mattias Bengtsson
On Wed, 2009-05-27 at 08:20 -0700, David Leimbach wrote:
 Interesting:
 
 
 http://www.facebook.com/careers/puzzles.php
 
 
 So they use Haskell at Facebook?


They could very well be having ghc installed on their puzzle test
server without using it elsewhere.
They got my attention though. Perhaps i should solve some puzzles
instead of studying for my exam!

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


Re: [Haskell-cafe] Getting the x out

2009-04-21 Thread Mattias Bengtsson
On Tue, 2009-04-21 at 17:49 -0700, michael rice wrote:
 How do I get the x out of Just x?
 
 Michael
 
 =
 
 safeDivision :: Float - Float - Maybe Float 
 safeDivision x y = if y == 0 then Nothing else Just (x/y)
 
 *Main Data.List safeDivision 10 5
 Just 2.0
 *Main Data.List 3 + (safeDivision 10 5)
 

This would do:
case safeDivision 10 5 of
  Just x - 3 + x
  Nothing - Nothing

The Maybe-monad might make this a bit more convenient:
ghci let plusthree a = do a' - a; return (a'+3)
ghci plusthree (Just 5)
Just 8


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


Re: [Haskell-cafe] Memoization-question

2008-12-16 Thread Mattias Bengtsson
On Fri, 2008-12-12 at 15:47 +0100, Bertram Felgenhauer wrote:
 GHC does opportunistic CSE, when optimizations are enabled. [...]

I see. Thank you!

Mattias

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


[Haskell-cafe] Memoization-question

2008-12-11 Thread Mattias Bengtsson
The program below computes (f 27) almost instantly but if i replace the
definition of (f n) below with (f n = f (n - 1) * f (n -1)) then it
takes around 12s to terminate. I realize this is because the original
version caches results and only has to calculate, for example, (f 25)
once instead of (i guess) four times.
There is probably a good reason why this isn't caught by the compiler.
But I'm interested in why. Anyone care to explain?

 main = print (f 27)
 
 f 0 = 1
 f n = let f' = f (n-1)
   in f' * f'

(compiled with ghc --make -O2)

Mattias

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


[Haskell-cafe] Unicode and Haskell

2008-09-09 Thread Mattias Bengtsson
Today i wrote some sample code after a Logic lecture at my university.
The idea is to represent the AST of propositional logic as an ADT with
some convenience functions (like read-/show instances) and then later
perhaps try to make some automatic transformations on the AST.
After construction of the Show instances i found the output a bit boring
and thought that some Unicode math symbols would spice things up. What
happens can be seen in the attached picture (only 3k, that's ok right?).
My terminal supports UTF-8 (when i do cat Logic.hs i can see the unicode
symbols properly).
What might be the problem?

regards
Mattias
module Logic where

infixr 5 :-:, :/\:, :\/:
infixr 5 --, /\, \/
infix 4 :|-:, :|=:
infix 4 |-, |=

data Logic = Formulae :|-: Formulae
   | Formulae :|=: Formulae

data Formulae = Formulae :-: Formulae
  | Formulae :/\: Formulae
  | Formulae :\/: Formulae
  | Formulae :-: Formulae
  | Not Formulae
  | P
  | Q
  | R
  | S


-- Operators
(--) = (:-:)
(/\)  = (:/\:)
(\/)  = (:\/:)
(-) = (:-:)
(|-)  = (:|-:)
(|=)  = (:|=:)
--a - b = (a -- b) /\ (b -- a)


-- Show

instance Show Logic where
showsPrec d (f1 :|-: f2) = shows f1 . showString  ⊢  . shows f2
showsPrec d (f1 :|=: f2) = shows f1 . showString  ⊨  . shows f2

p  = 5
p' = 6
instance Show Formulae where
showsPrec d (f1 :-: f2)  = showBinaryF d f1  →  f2
showsPrec d (f1 :/\: f2)  = showBinaryF d f1  ⋀  f2
showsPrec d (f1 :\/: f2)  = showBinaryF d f1  ⋁  f2
showsPrec d (f1 :-: f2) = showBinaryF d f1  ↔  f2
showsPrec d (Not f) = showString ¬
  . showsPrec p' f
showsPrec _ P = showString p
showsPrec _ Q = showString q
showsPrec _ R = showString r
showsPrec _ S = showString s

showBinaryF d f1 op f2 = showParen (d  p) 
 $ showsPrec p' f1
 . showString op 
 . showsPrec p' f2

import Logic
main = do print (P -- Q |- (Not P) -- (Not Q))

signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Unicode and Haskell

2008-09-09 Thread Mattias Bengtsson
On Wed, 2008-09-10 at 00:01 +0200, Mattias Bengtsson wrote:
 [..]
 What happens can be seen in the attached picture[..]

And here it is...
attachment: Screenshot-Terminal2.jpg

signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Unicode and Haskell

2008-09-09 Thread Mattias Bengtsson
On Wed, 2008-09-10 at 00:07 +0200, Thomas Davie wrote:
 import Prelude hiding (print)
 import System.IO.UTF8
 
 main = print lots of UTF8
 

Thanks a lot!


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Mattias Bengtsson
On Thu, 2008-05-15 at 11:31 -0700, Don Stewart wrote:
 I've written an extended post on how to understand and reliably optimise
 code like this, looking at it all the way down to the assembly.
 
 The result are some simple rules to follow for generated code as good
 as gcc -O2.
 
 Enjoy,
 
 http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast

A good read. 

Side point: Is the name go part of the idiom you mentioned? I
sometimes use the same practise but usually just calls the worker the
same as the real function with an added prime (').


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why functional programming matters

2008-01-24 Thread Mattias Bengtsson
On Thu, 2008-01-24 at 21:11 +, Paul Johnson wrote:
[snip]
// Get the Foo that was most recently updated.
Foo latestUpdate (Iterator Foo iterator) {
[...]
}
 
 This takes an iterator over some collection of Foos and finds the one 
 with the highest value of updateTime.  9 lines of code, or 12 with the 
 closing curly brackets.
 
 In Haskell this is so short and obvious you probably wouldn't bother 
 declaring it as a function, but if you did, here it is:
 
-- Find the Foo that was most recently updated.
latestUpdate :: [Foo] - Foo
latestUpdate foos = maximumBy (comparing updateTime) foos
 
 Of course you could always write it in point-free format, but I think 
 that would be over-egging things.

To have a fair comparison you'd have to use some typeclass (Foldable
would be right?) that supports different types of collections.

 import Data.Foldable as F
 
 latestUpdate :: Foldable a = [a] - a
 latestUpdate = F.maximumBy (comparing updateTime)

But yeah your point is very very valid. I've programmed some Java in my
days and while i wouldn't call myself an expert i don't see any
immediate unawkward abstractions that can be performed in the java
code. 
If you have all Foo's implement a method getProperty(String) that
takes a String and returns the property of that class instance you
_could_ implement the static method (correct java-lingo?)
maximumBy(String s) that is roughly like this:

class MyClass {
  public static Foo maximumBy (Iterator Foo iterator, String s) {
 long max = 0;
 Foo maxFoo = Null;
 while (iterator.hasNext()) {
item = iterator.getNext();
if (item.getProperty(s).compareTo(max)) {
   max = item.updateTime;
   maxFoo = item;
}
 }
 return maxFoo;
  }
}

and then
Foo latestUpdate (Iterator Foo i) {
   return MyClass.maximumBy(i,latestUpdate);
}

Totally untested code ofcourse...
The awkward part obviously comes from the fact that properties aren't
functions that you can pass to the maximumBy-method.

Anyhow, Haskell's nice Polymorphism is surely a good argument for it
(but not for functional programming per se right?)

Mattias

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


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Mattias Bengtsson
On Wed, 2008-01-09 at 15:06 +, Dougal Stanton wrote:
 Have a look at the ueber-retrospective on Haskell, fifty-five pages of
 all the history and motivation one could possibly want.
 
 http://research.microsoft.com/~simonpj/papers/history-of-haskell/
 
 It's interesting reading, I promise! ;-)

I actually think it was a really interesting read when i read it a year
ago or so! :)

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


Re: [Haskell-cafe] Re: Web server continued

2008-01-02 Thread Mattias Bengtsson
On Mon, 2007-12-31 at 12:36 +, Joost Behrends wrote:
 And concerning SQL: I like the parts of the language - all capitalized - as
 landmarks in my code, even in modified forms like:
 
  SELECT number, customer FROM  ++ currcols ++ 
 
 Here i see from afar, what the code around this line does.

And the backside of treating SQL as strings, like you do here, is that
you are able to construct malformed SQL and the errors you get from this
can only be handled at runtime. This is the reason HaskellDB (and other
similar projects?) exists. 
I too am not sure that HaskellDB is the perfect solution though. It
provides both type safety and an abstraction. Personally i'd be fine
with just the type safety. Not sure if it's feasible to embed the whole
SQL-syntax in Haskell using just ADT's and combinators though.

Mattias


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2007-12-19 Thread Mattias Bengtsson
On Wed, 2007-12-19 at 13:03 -0500, Steve Lihn wrote:
[snip]
 I do come aross a question while reading the DSL page on Wikipedia.
 
 http://en.wikipedia.org/wiki/Domain-specific_programming_language
 
 In the Disadvantage section (near the end), there is an item -- hard
 or impossible to debug. Can anybody explain why or what it means? 

I can't think of anything in the pure concept of Domain Specific
Languages that would make them hard or impossible to debug. You'd only
have to write a good debugger for the language.

 And how does it apply to Haskell?

A DSL embedded in Haskell has the advantage (and disadvantage) of being
normal Haskell code, hence the normal Haskell debuggers will work.
However, if the EDSL is presented as an entirely new language then
non-Haskellers will obviously have problems understanding the generic
Haskell debugger and error messages.

Mattias

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


[Haskell-cafe] Folding Integrals

2007-12-11 Thread Mattias Bengtsson
I found myself writing this for an Euler-problem:

 digits :: Int - [Int]
 digits i | i  10= [i]
  | otherwise = i `mod` 10 : digits ( i `div` 10 )

And i realised it was quite some time ago (before this function) i had
actually written any explicitly recursive function. I managed to finish
the Euler problem however and i was happy about that.
However it frustrated me that i couldn't find a nice way to abstract
away that explicit recursion but today i managed to! :)
My first thought was that the solution probably was using some function
like scanr, mapAccum or unfoldr to do it (especially the name of unfoldr
made me think that it would be the solution). 
After abstracting my digits function i realised that it wasn't anything
more than a fold over the Int type (treating the Int as a sequence of
digits). i `mod` 10 and i `div` 10 would be nothing more than the
head and tail functions (that corresponds to the (:) pattern matching). 

This is what i came up with finally:
(I'm not 100% sure on the foldr- and foldl names though. Not sure if the
semantics are correct, perhaps the function names should be switched?)

 module FoldIntegral (foldr, foldl) where 
 import Prelude hiding (foldr,foldl,head,tail)
 
 head, tail :: Integral a = a - a
 head i = i `mod` 10
 tail i = i `div` 10
 
 foldr :: Integral a = (a - b - b) - b - a - b
 foldr f z i 
 | i == 0= z
 | otherwise = foldr f (h `f` z) t
 where h = head i
   t = tail i
 
 foldl :: Integral b = (a - b - a) - a - b - a
 foldl f z i 
 | i == 0= z
 | otherwise = (foldl f z t) `f` h
 where h = head i
   t = tail i

Which would make the digits function a one-liner:

 digits = foldr (:) [] 

I hope someone enjoys this.

Mattias


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] unification would give infinite type

2007-12-04 Thread Mattias Bengtsson

Rafael skrev:

Hi... I give this error using hugs for the code:

---
f = foldl (\x y - add x y) 0 [1,2,3]
add x y = return (x + y)
---
I try:

f = foldl (\x y - counter x y) (return 0) [1,2,3]

but it dont solve,  and with ghci:


Occurs check: cannot construct the infinite type: b = m b
  Expected type: b
  Inferred type: m b
In the expression: add x y
In a lambda abstraction: \ x y - add x y
  
return isn't what you would expect it is if you come from an imperative 
programming background.
It might be a bit early in your haskell journey for this but return is 
one of the two most important functions in the Monad typeclass and not a 
language construct as in C and Java.

Anyhow, try this definition of add instead:
 add x y = x + y
or for short:
 add = (+)

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


[Haskell-cafe] Re: [Haskell] Recruiting functional programmers

2007-11-20 Thread Mattias Bengtsson

 Interested in recruiting Haskell programmers from Chalmers/Gothenburg
 university? As an experiment, I am planning a recruitment event here in
 December-see www.jobs-in-fp.org for how to take part.


Just checked my calendar and all according to Murphy's law this had to be
the weekend when i'm in Stuttgart on vacation.
Will there be more events if this one turns out successful?

/Mattias

-- 



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


Re: [Haskell-cafe] IDE?

2007-06-16 Thread Mattias Bengtsson
On Sat, 2007-06-16 at 17:10 +0100, Andrew Coppin wrote:
 It's a text-mode editor. quod erat demonstrandum.
 
 Since it only operates in text-mode, it cannot possibly provide things 
 like clickable fold points, or a side-bar containing a bunch of icons 
 representing the objects in the current file, or a spell checker, or an 
 interactive debugger, or any of those other features that require a GUI. 
 (I am *really* not a fan of ASCII art graphical user interfaces.)

Emacs has had a real GUI for many years. (At least since '98 when i
started using it).


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] nested maybes

2007-02-04 Thread Mattias Bengtsson
On Sun, 2007-02-04 at 19:54 +0530, Martin DeMello wrote:
 I have a Data.Map.Map String - (Layout, [String]) as follows:
 
 type Anagrams = [String]
 type Cell = (Layout, Anagrams)
 type WordMap = Map.Map String Cell
 
 exists str wmap =
   let a = Map.lookup (sort str) wmap in
   case a of
Nothing - False
Just x - case (find (== str) (snd x)) of
   Nothing - False
   _   - True
 
 the existence test looks ugly - any more compact way to write it?
 

Using the Maybe Monad is one solution i think (as in: i _think_ this
should work):

findIt str wmap = do 
  a - Map.lookup (sort str) wmap
  return $ find (== str) (snd a)

exists str wmap = 
  case findIt str wmap of
Nothing - False
Just _ - True

The Maybe monad is very nice for abstracting away all those
case-expressions.


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] snd and tuples of various sizes...

2007-02-02 Thread Mattias Bengtsson
On Thu, 2007-02-01 at 21:01 -1000, Tim Newsham wrote:
 instance Second [a] a where
  snd [] = error don't got none
  snd (x:y:xs) = y 

Would'nt that instance mean this:
  snd [] produces error
  snd [x] gives []


I'd implement it something like this (if this works?):

instance Second [a] (Maybe a) where
 snd [] = Nothing
 snd [x] = Nothing
 snd (x:y:xs) = Just y 


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newTArrayIO

2007-01-26 Thread Mattias Bengtsson
On Fri, 2007-01-26 at 11:34 -0800, Chad Scherrer wrote:
 This seems like a natural thing to have around, but it's not in GHC
 6.6...
 
 newTArrayIO :: (Enum i, Ix i) = (i, i) - a - IO (TArray i a)
 newTArrayIO (a,b) = liftM (TArray . listArray (a,b)) . sequence .
 zipWith ignore [a..b] . repeat . newTVarIO 
   where ignore = flip const
 
 I haven't done any testing with this beyond type checking, but it
 seems like it could be useful for similar cases to newTVarIO. Has
 anyone else played with anything similar?
 

Agree. I learned lots regarding technologies that seemed like pure magic
before, like GADT's and fundeps etc.
Definately a good read.

Mattias


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] newTArrayIO

2007-01-26 Thread Mattias Bengtsson
On Fri, 2007-01-26 at 23:26 +0100, Mattias Bengtsson wrote:
 On Fri, 2007-01-26 at 11:34 -0800, Chad Scherrer wrote:
  This seems like a natural thing to have around, but it's not in GHC
  6.6...
  
  newTArrayIO :: (Enum i, Ix i) = (i, i) - a - IO (TArray i a)
  newTArrayIO (a,b) = liftM (TArray . listArray (a,b)) . sequence .
  zipWith ignore [a..b] . repeat . newTVarIO 
where ignore = flip const
  
  I haven't done any testing with this beyond type checking, but it
  seems like it could be useful for similar cases to newTVarIO. Has
  anyone else played with anything similar?
  
 
 Agree. I learned lots regarding technologies that seemed like pure magic
 before, like GADT's and fundeps etc.
 Definately a good read.


Hrrm. This was meant as a reply to Justin Bailey, sorry.


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] generating javascript

2006-11-28 Thread Mattias Bengtsson
On Tue, 2006-11-28 at 18:36 -0500, jeff p wrote:
 Hello,
 
   Are there any Haskell tools to generate javascript? Has anyone made
 a combinator library for
 javascript?

There's a Google SoC-project made by a friend of mine for JavaScript
support in Haskell Server Pages:
http://csmisc14.cs.chalmers.se/~bjornson/soc/

It's a combinator library, but i'm not sure it's what you really need
though. :)

regards

Mattias


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Substitute for records?

2006-04-10 Thread Mattias Bengtsson
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


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell] Re: Trying On Learn Haskell Web Server

2006-03-07 Thread Mattias Bengtsson

On Tue, 2006-03-07 at 00:06 +0100, Niklas Broberg wrote:
 On 3/6/06, Graham Klyne [EMAIL PROTECTED] wrote:
  - An easy way to map incoming URIs to specific functions (hmm.. or to 
  monadic
  values, I think)
 
 I don't think I understand what you're after exactly, but I'm sure
 it's interesting, care to explain a bit further? :-)

Hm, i remember seeing this in ruby on rails i think.
You would like to be able to map http://www.domain.com/show or
http://www.domain.com/show etc. to haskell-functions that spits out
webpages. With all this defined in one file?

  - Easy mapping from Haskell data structures to underlying SQL - what would 
  be
  called an Object-Relational Mapper (ORM) in OO languages
 
 Some of our students are working on bringing the power of Ruby/Rails
 to HSP, with emphasis on smooth database interfacing. Not sure exactly
 what this entails though, I've never used Rails... :-)
 

This is basically some sort of database abstraction which is somewhat
inspired by ActiveRecord in Rails. In short we let the programmer define
its database in a spec-file. Mostly things you'd do anyway using a list
of CREATE TABLE in an SQL-file. 
However we have a different syntax and some extra attributes that can be
set to define what sort of relations different tables has to each other
(one to one, one to many and many to many). We plan on extending this
later (maybe software TRIGGER's and CASCADE'ing and some sort of
contstraints).

This spec-file is then supposed to create an empty database conforming
to the spec and Haskell modules containing HaskellDB defintions together
with generated helper functions for retreiving data from your database.
This together with support for Higher Order Queries should make it
both easy and fast to do database actions without giving up on
flexibility. At least that is our goal.

 
  - Handling of interaction with a browser-side Javascript library for 
  smoother
  AJAX support
 
 This is not currently present in HSP, but they are surely on the
 conceptual todo-list. There is a design for a crude JavaScript
 support, but we'd certainly need more.

This is quite important.

  - 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. Two guys in my group is working on this. Haven't made any progress
as of yet though.

  I think that continuation-based web session state management, ala
  Smalltalk/Seaside, would be a very natural fit for a Haskell framework -- 
  all
  handled by a Web session monad, maybe.  (Or maybe I just don't know what 
  I'm
  talking about ;)
 
 This is by far the biggest drawback of HSP today. There is no
 high-level support for continuations (other than explicitly defined
 continuations at top level).

I would really like to know exactly what this means. Are there any
examples or papers on this?

  How far are we from having such a framework for Haskell?
 
 Depends on how many people would be willing to invest time in it.
 Right now we have students at Chalmers working on a project that aims
 towards such a framework, but they can only do so much in the time
 they have. We would surely welcome any help we could get. :-)

Hopefully we will a real homepage up pretty soon and tell the world what
we are working on. Hopefully some of us would like to actively continue
on this project after spring when we need to show something.

Mattias 

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