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

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

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

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)]

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

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 +

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

[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

[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

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

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

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,

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

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! ;-)

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

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

[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

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

[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

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

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

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]

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 .

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

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:

[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