Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Lennart Augustsson
Haskell doesn't provide such a value, but you could easily compute it from from the values given in the RealFloat class. It tells you the base, number of digits in mantissa, etc. As for using such an eps in a convergence test I'd be very careful. How do you know that your iteration doesn'

Re: [Haskell-cafe] Haskell DLL crashes Excel

2006-09-25 Thread Lennart Augustsson
I don't think GHC is to blame in this case. If you follow all the API (ABI) guidelines for building XLLs things work fine. But there's a lot of things to get right. -- Lennart On Sep 25, 2006, at 05:16 , Simon Peyton-Jones wrote: Andreas, Nikunj, and others I don't have any experie

Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Lennart Augustsson
Or even shorter: subst e l = concatMap $ \x->if x==e then l else [x] I kinda like the list comprehension version too subst e l1 l2 = [ r | x <- l2, r <- if x==e then l1 else [x] ] On Sep 18, 2006, at 10:54 , Jón Fairbairn wrote: Andrea Rossato <[EMAIL PROTECTED]> writes: On Mon, Sep 18, 2

Re: [Haskell-cafe] Re: evaluate vs seq

2006-09-15 Thread Lennart Augustsson
collecting!) -- Lennart On Sep 15, 2006, at 07:59 , Lennart Augustsson wrote: No, I wasn't suggesting that evaluate can tell the difference, just that you can add dubious "functions". You can evaluate with eager evaluation and some kind of threads +fair scheduler. Both pH an

Re: [Haskell-cafe] Optimization problem

2006-09-15 Thread Lennart Augustsson
I agree, the function can be tricky to use. But that's not our problem, we are only to implement it. :) On Sep 15, 2006, at 05:28 , Brian Brunswick wrote: On 15/09/06, Lennart Augustsson <[EMAIL PROTECTED]> wrote: On Sep 14, 2006, at 03:05 , Rohan Drape wrote: >>>

Re: [Haskell-cafe] Re: evaluate vs seq

2006-09-15 Thread Lennart Augustsson
not sure pH ever got the fair scheduler.) -- Lennart On Sep 15, 2006, at 05:00 , [EMAIL PROTECTED] wrote: Lennart Augustsson wrote: No, you were right the first time. :) The denotational semantics is the important one. Haskell can be executed by other means than graph reduction. (T

Re: [Haskell-cafe] Bit string

2006-09-14 Thread Lennart Augustsson
It's hard to tell what the best representation is if you don't know what the operations that you are going to perform are. If all you are going to do is I/O of bitstrings, then [Bool] could be great. If you need to do bitwise boolean ops then Integer is a wise choice. -- Lennart

Re: [Haskell-cafe] Re: evaluate vs seq

2006-09-14 Thread Lennart Augustsson
On Sep 14, 2006, at 16:20 , [EMAIL PROTECTED] wrote: Michael Shulman wrote: On 9/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: So `seq` forces its first argument. When we define f x = x `seq` (Return x) we thereby get f _|_== _|_ f [] == Return [] f (x:xs) == Return (x:x

Re: [Haskell-cafe] Optimization problem

2006-09-14 Thread Lennart Augustsson
On Sep 14, 2006, at 03:05 , Rohan Drape wrote: splitStreams [(3,x),(1,y),(3,z),(2,w)] [(3,[x,z]),(1,[y]),(2,[w])] [snip] Furthermore it should work on infinite lists. It can't eat the whole list before producing any output. This doesn't seem to make sense? Only at the end of the list can

Re: [Haskell-cafe] Re: Numeric type classes

2006-09-13 Thread Lennart Augustsson
The sum function really only needs the argument list to be a monoid. And the same is true for the product function, but with 1 and * as the monoid operators. Sum and product are really the same function. :) I don't think Haskell really has the mechanisms for setting up an algebraic class hi

Re: [Haskell-cafe] nondet function

2006-09-10 Thread Lennart Augustsson
To make it referentially transparent you might want to consider adding 'por', parallel or, instead. It's like (||), but symmetric in its treatment of bottom. -- Lennart On Sep 10, 2006, at 00:21 , Ashley Yakeley wrote: Is it possible to write nondet? nondet :: a -> a -> a no

Re: [Haskell-cafe] Monad laws

2006-09-07 Thread Lennart Augustsson
Brian, Are you really sure Haskell compilers do that optimization? I would regard a compiler that does optimizations that are justified by laws that the compiler cannot check as broken. -- Lennart On Sep 7, 2006, at 08:50 , Brian Hulley wrote: Deokhwan Kim wrote: What is the pract

Re: Re[2]: [Haskell-cafe] Reading integers

2006-09-07 Thread Lennart Augustsson
What about negative numbers? Also, don't use (ord c - ord '0'), it doesn't work with Unicode digits. That's why there is a digitToInt function. -- Lennart On Sep 7, 2006, at 02:12 , Bulat Ziganshin wrote: readI = foldl f 0 where f m c | isDigit c = fromIntegral (ord c - ord '0') +

Re: [Haskell-cafe] Re: does the compiler optimize repeated calls?

2006-09-06 Thread Lennart Augustsson
Furthermore, doing that optimization (common subexpression elimination) can lead to space leaks. So you should not count on the compiler doing it. Besides, I often find it more readable and less error prone to name a common subexpression; only one place to change when you need to change t

Re: [Haskell-cafe] Re: how do you debug programs?

2006-09-06 Thread Lennart Augustsson
r real use. -- Lennart On Sep 6, 2006, at 08:13 , Tamas K Papp wrote: On Wed, Sep 06, 2006 at 06:33:32AM -0400, Lennart Augustsson wrote: I've also used Visual Studio, and I wouldn't mind having something like that for Haskell. But I have to agree with Jon, I think the best wa

Re: [Haskell-cafe] Re: how do you debug programs?

2006-09-06 Thread Lennart Augustsson
I've also used Visual Studio, and I wouldn't mind having something like that for Haskell. But I have to agree with Jon, I think the best way of debugging is to understand your code. I think people who come from imperative programming come with a mind set that you understand your code by s

Re: [Haskell-cafe] Why does this program eat RAM?

2006-09-04 Thread Lennart Augustsson
The x+1 looks suspicious. On Sep 4, 2006, at 23:03 , John Goerzen wrote: I have the below program, and I'm trying to run it on an input of about 90MB. It eats RAM like crazy, and I can't figure out why. I do know that the problem is not my custwords function (as you can see, I replaced th

Re: Quantification in free theorems (Was: [Haskell-cafe] Exercise in point free-style)

2006-09-04 Thread Lennart Augustsson
I'd like to see a mix of the two systems. Top level quantifiers should be optional; they often don't improve readability. -- Lennart On Sep 4, 2006, at 04:21 , Janis Voigtlaender wrote: [EMAIL PROTECTED] wrote: G'day all. Quoting Donald Bruce Stewart <[EMAIL PROTECTED]>: Get some

Re: [Haskell-cafe] A free monad theorem?

2006-09-04 Thread Lennart Augustsson
from ma. Is that sufficiently close to what you mean or do I still not understand what you're trying to convey? Cheers, Daniel On Sep 3, 2006, at 12:32 , Daniel Fischer wrote: Am Sonntag, 3. September 2006 15:39 schrieb Lennart Augustsson: Well, bind is extracting an 'a'. I c

Re: [Haskell-cafe] Re: Re: A free monad theorem?

2006-09-03 Thread Lennart Augustsson
where there is an 'a' lurking, or f could not be called. Perhaps you don't want to call that "extraction", and that's fine by me. :) -- Lennart On Sep 3, 2006, at 12:32 , Daniel Fischer wrote: Am Sonntag, 3. September 2006 15:39 schrieb Lennart Aug

Re: [Haskell-cafe] Re: Re: A free monad theorem?

2006-09-03 Thread Lennart Augustsson
Well, bind is extracting an 'a'. I clearly see a '\ a -> ...'; it getting an 'a' so it can give that to g. Granted, the extraction is very convoluted, but it's there. -- Lennart On Sep 2, 2006, at 19:44 , Udo Stenzel wrote: Benjamin Franksen wrote: Sure. Your definition of bind

Re: [Haskell-cafe] Re: Exercise in point free-style

2006-09-01 Thread Lennart Augustsson
An easy way to solve this is to ask lambdabot. Log on to the Haskell IRC channel: lennart: @pl \ f l -> l ++ map f l lambdabot: ap (++) . map Notice how it's much shorter than the Hughes' solution. :) -- Lennart On Sep 1, 2006, at 13:11 , John Hughes wrote: From: Julien Oster <[EM

Re: [Haskell-cafe] haskell -> fpga

2006-08-30 Thread Lennart Augustsson
General Haskell constructs map really poorly to FPGAs. You could define a subset that maps nicely, though. But as far as I know noone has made such a compiler. It's a rather big undertaking. You could look at Cryptol and Bluespec, they are languages with similarities to Haskell better suit

Re: [Haskell-cafe] monads once again: a newbie perspective

2006-08-26 Thread Lennart Augustsson
I like sigfpe's introduction to monads: http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads- and.html -- Lennart On Aug 26, 2006, at 14:04 , Andrea Rossato wrote: Il Fri, Aug 25, 2006 at 01:13:58PM -0400, Cale Gibbard ebbe a scrivere: Hey cool, a new monad tutorial!

Re: [Haskell-cafe] Re: iterative algorithms: how to do it in Haskell?

2006-08-21 Thread Lennart Augustsson
equal ( _ : _ : _) = error "Bad operands to equal" equal_ = error "Not enough operands on stack" -- Lennart On Aug 21, 2006, at 04:42 , Gene A wrote: Lennart and all, On 8/19/06, Lennart Augustsson <[EMAIL PROTECTED]> wrote: There are much be

[Haskell-cafe] Re: iterative algorithms: how to do it in Haskell?

2006-08-19 Thread Lennart Augustsson
ation and some other things that are more tedious to write as primatives in other languages.. The only other language that was as easy to get to this stage with was scheme. Sorry for the ramble, gene On 8/19/06, Lennart Augustsson <[EMAIL PROTECTED]> wrote: On Aug 19, 2006, at 05:14

Re: [Haskell-cafe] Re: iterative algorithms: how to do it in Haskell?

2006-08-19 Thread Lennart Augustsson
On Aug 19, 2006, at 05:14 , Henk-Jan van Tuyl wrote: [...] *Iteration> fromtoby 12 42 3 (flip (**) 0.33) fromtoby 12 42 3 (**0.33) And why approximate so much? fromtoby 12 42 3 (** (1/3)) ___ Haskell-Cafe mailing list Haskell-

Re: [Haskell-cafe] A restricted subset of CPP included in a revisionof Haskell 98

2006-08-17 Thread Lennart Augustsson
On Aug 17, 2006, at 17:11 , Brian Hulley wrote: On Thursday, August 17, 2006 7:54 PM, Brian Smith wrote: I want to have conditionals limited in their placement to make things easier for refactoring tools. But, I don't have any ideas about how to deal with conditional exports without allowing

Re: [Haskell-cafe] A restricted subset of CPP included in a revision of Haskell 98

2006-08-17 Thread Lennart Augustsson
Even though I'm largely responsible for making CPP available in a Haskell compiler I think it's an abomination. It should be avoided. If we standardize it, people will use it even more. I think we should discourage it instead, then looking at exactly what it's used for and supplying sane ve

Re: [Haskell-cafe] Why shouldn't variable names be capitalized?

2006-08-04 Thread Lennart Augustsson
There are two places where confusion could arise if you didn't have the case distinction in Haskell: pattern matching (does a name refer to a constructor or not) and type expressions (is it a type variable or not). In Haskell the distinction is made by case, but this is far from the only

Re: [Haskell-cafe] Unix gurus, help me please

2006-07-17 Thread Lennart Augustsson
On Jul 17, 2006, at 10:04 , Bulat Ziganshin wrote: #!/usr/bin/env runhaskell instead of #!/usr/bin/runhaskell at the start of Setup.hs file. Is that really better? Yes, much better. I think it's crazy to have runhaskell installed in /usr/bin. It should be somewhere in your path, but n

Re: [Haskell-cafe] Combinations

2006-06-06 Thread Lennart Augustsson
Sounds like cartesian product to me. So you could try combinations [] = [[]] combinations (xs:xss) = liftM2 (:) xs (combinations xss) -- Lennart [EMAIL PROTECTED] wrote: Hi, I need a functions which takes as argument a list of lists like this one: [[1,2],[3],[4]] and gives me a list

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-29 Thread Lennart Augustsson
Adrian Hey wrote: I've written about 5 lines of USB devices drivers for *BSD (in C). They work from the bare metal and up. They contain no global mutable state (except for variables that define debugging levels, because you need to access these from the in-kernel debugger). Yes, I was awar

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-27 Thread Lennart Augustsson
Not to fuel the flame war, I will limit myself to two comments. Adrian Hey wrote: Or put another way, would it be possible to implement the socket API, exactly as it currently is, entirely in Haskell, starting with nothing but hardware? I don't believe it is possible, but perhaps somebody can sh

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-24 Thread Lennart Augustsson
Adrian Hey wrote: . I was going to respond, but Cale very eloquently said most of what I was thinking. Let me just add one thing. Sometimes you hear the argument "I need a global IORef here because it's to track the use of my single screen" (or keyboard, or elevator, or some some other gizm

Re: [Haskell-cafe] Current situation regarding global IORefs

2006-04-23 Thread Lennart Augustsson
Robert Dockins wrote: Ahhh... the singleton pattern. There is a debate among OO theorists about whether the singleton pattern is actually a good idea. I tend to side with those who say that it is Just Wrong. The reality is that "singletons" are only unique within some scope (OS process, VM

Re: [Haskell-cafe] "show" for functional types

2006-04-05 Thread Lennart Augustsson
Brian Hulley wrote: Greg Buchholz wrote: Hmm. It must be a little more complicated than that, right? Since after all you can print out *some* functions. That's what section 5 of _Fun with Phantom Types_ is about. Here's a slightly different example, using the AbsNum module from... http:

Re: [Haskell-cafe] "show" for functional types

2006-04-05 Thread Lennart Augustsson
Neil Mitchell wrote: Hi, First, its useful to define referential transparency. In Haskell, if you have a definition f = not Then this means that anywhere you see f, you can replace it with not. For example "f True" and "not True" are the same, this is referentially transparent. Now lets def

Re: [Haskell-cafe] how would this be done? type classes? existential types?

2006-03-16 Thread Lennart Augustsson
You can't give unRs a type. What I usually do in this situation is to make the Rs type a Resource too. instance Resource Rs where resourceName(Rs a) = resourceName a resourceAdvance (Rs a) = Rs (resourceAdvance a) resourceStarved (Rs a) = resourceStarved a resour

Re: [Haskell-cafe] Re: request for code review

2006-03-12 Thread Lennart Augustsson
Shannon -jj Behrens wrote: lexString ('*':cs) = (classifyString "*", cs) lexString (c:cs) = (classifyString [c], cs) The first line isn't needed, it does the same as the second line. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.h

Re: [Haskell-cafe] PrefixMap: code review request

2006-02-27 Thread Lennart Augustsson
David F.Place wrote: partList :: Ord k => [([k],v)]->[k]->[(k,[([k],v)])] partList pairs alphabet = reverse . fst $ foldl' f ([],pairs) alphabet where f (result,pairs) l = (result',rest) where (part,rest) = span ((==l) . head . fst) pairs result' = if null part

Re: [Haskell-cafe] rounding errors with real numbers.

2006-02-26 Thread Lennart Augustsson
Well, if you are relying on exact results from floating point arithmetic you're in trouble no matter what you do. I would just ignore the slight error and when finally printing the results do some rounding. Trying to fudge things is just going to bite you somewhere else. (BTW, I much prefer the

Re: [Haskell-cafe] HaXml: ampersand in attribute value

2006-02-17 Thread Lennart Augustsson
But speaking of HaXml bugs, I'm pretty sure HaXml doesn't handle % correctly. It seem to treat % specially everywhere, but I think it is only special inside DTDs. I have many XML files produced by other tools that the HaXml parser fails to process because of this. -- Lennart Malcolm Wa

Re: [Haskell-cafe] Haskell XSLT interpreter?

2006-02-12 Thread Lennart Augustsson
Neil Mitchell wrote: In what way is the document() function not pure? See [http://www.w3schools.com/xsl/func_document.asp]. In particular their example: i.e. this function needs to load the file celsius.xml. Note that instead of celsius.xml there could be an arbitrary complex expression here

Re: [Haskell-cafe] Re[2]: strict Haskell dialect

2006-02-11 Thread Lennart Augustsson
Bulat Ziganshin wrote: Hello Wolfgang, Saturday, February 11, 2006, 3:17:12 PM, you wrote: each and every monadic operation is a function! WJ> What do you mean with "monadic operatation"? (>>=), (>>) and return are, of WJ> course, functions but an I/O action like getChar is *not* a functio

Re: [Haskell-cafe] Why is $ right associative instead ofleftassociative?

2006-02-05 Thread Lennart Augustsson
John Hughes wrote: What, no list comprehensions?? No. I think the do notation is good enough. I'd disagree--sequencing is special, and lists represent it directly. Don't forget, also, that lists are also much more prevalent in beginners' code--and nice notation for beginners helps get peop

Re: [Haskell-cafe] Why is $ right associative instead ofleftassociative?

2006-02-05 Thread Lennart Augustsson
John Hughes wrote: > Quoting Paul Hudak <[EMAIL PROTECTED]>: > >> Actually, one of the main reasons that we chose (:) is that that's what >> Miranda used. So, at the time at least, it was not entirely clear what >> the "de facto universal inter-language standard" was. > Phil Wadler argued

Re: [Haskell-cafe] formal methods & functional programming

2006-01-15 Thread Lennart Augustsson
Robin Green wrote: 2. Dependent types: By programming in a dependently-typed functional programming language such as the research language Epigram, it is possible to write functional programs whose types force them to be correct. See for example "Why Dependent Types Matter" by Thorsten Altenki

Re: [Haskell-cafe] Re: What does the Haskell type system do with "show (1+2)"?

2006-01-13 Thread Lennart Augustsson
Daniel Fischer wrote: Now the question is, could that restriction be lifted, i.e., would it be possible/worthwhile to let defaulting also take place if user defined classes are involved? The current defaulting mechanism in Haskell is very, very conservative. You could easily relax the restrict

Re: [Haskell-cafe] Expanding do notation

2006-01-08 Thread Lennart Augustsson
Daniel Fischer wrote: Cool. So let's see if I got it. If I have n <- readIO ... mapM_ (func n) list ... in my programme, the runtime system will/might build object code for func n that is then used instead of using the general code for func and supplying both arguments to that? Tha

Re: [Haskell-cafe] binary IO

2005-12-28 Thread Lennart Augustsson
Joel Reymont wrote: You are right in that I spent the first few weeks learning. By now I know that pickling is the bottleneck, though. The timeleak code is very simple. It forks X threads where each thread opens a file for reading. Why on earth do you want each tread to open the file and un

Re: [Haskell-cafe] Haskell vs OCaml

2005-12-25 Thread Lennart Augustsson
Branimir Maksimovic wrote: Great! what are constrains on [begin..end] could they be some type which supports (+) , but not Int. Anything in the Enum class (so it doesn't even have to support (+)). Many things are in the Enum class. Last question is: Does creation of list of functions humpers p

Re: [Haskell-cafe] Haskell vs OCaml

2005-12-25 Thread Lennart Augustsson
Branimir Maksimovic wrote: I've found that Haskell is pretty good in implementing recursive algorithms. Problem cames when one want's to implement non recursive algorithm by terms of recursion as Haskell does not support loops. Perhaps if we can get loops, situation will improve, but then that w

Re: [Haskell-cafe] Optimizing a high-traffic network architecture

2005-12-16 Thread Lennart Augustsson
John Meacham wrote: On Thu, Dec 15, 2005 at 02:02:02PM -, Simon Marlow wrote: With 2k connections the overhead of select() is going to start to be a problem. You would notice the system time going up. -threaded may help with this, because it calls select() less often. we should be usin

[Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-15 Thread Lennart Augustsson
Very cool! :) [EMAIL PROTECTED] wrote: Stefan Monnier wrote: I expected at first you were doing some funky type class molestation so you can use "djinn" in your code and let Haskell fill it in. That has already been done: De-typechecker: converting from a type to a term http://www.haskell.

Re: [Haskell-cafe] Re: Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-14 Thread Lennart Augustsson
I've certainly thought of providing the functionality you want, but I've not done that yet. Internally djinn uses some kind of ASTs, it might be possible to use GADTs to do what you want in a type safe way. If not it should be possible to use Dynamic. -- Lennart Stefan Monnier wrote:

[Haskell-cafe] Re: [Haskell] Re: Announcing Djinn, new version 2004-12-13

2005-12-14 Thread Lennart Augustsson
Well, the proof search is terminating (and complete) so it has to stop somewhere. That happens to be result with this particular search strategy. -- Lennart Chung-chieh Shan wrote: Lennart Augustsson <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTE

[Haskell-cafe] Announcing Djinn, new version 2004-12-13

2005-12-13 Thread Lennart Augustsson
There is a new version of Djinn available, with two notable new features: Haskell data types can be defined and the found functions are sorted (heuristically) to present the best one first. To play with Djinn do a darcs get http://darcs.augustsson.net/Darcs/Djinn or get http://darcs.augustsso

[Haskell-cafe] Announcing Djinn, version 2004-12-11, a coding wizard

2005-12-11 Thread Lennart Augustsson
Howdy, y'all! I've written a small program that takes a (Haskell) type and gives you back a function of that type if one exists. It's kind of fun, so I thought I'd share it. It's probably best explained with a sample session. calvin% djinn Welcome to Djinn version 2005-12-11. Type :h to g

Re: [Haskell-cafe] Differences in optimisiation with interactive and compiled mo

2005-12-10 Thread Lennart Augustsson
Have you tried using any of the standard string searching algorithms to speed up the search? Like BM or KMP? -- Lennart Branimir Maksimovic wrote: From: Tomasz Zielonka <[EMAIL PROTECTED]> To: Branimir Maksimovic <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED], haskell-cafe@haskell.org S

Re: [Haskell-cafe] Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-24 Thread Lennart Augustsson
Shae Matijs Erisson wrote: Gregory Woodhouse <[EMAIL PROTECTED]> writes: My knowledge of functional programming is pretty much limited to Haskell, Scheme, and a smattering of Common Lisp. Are there languages other than Haskell that explicitly use monads? How about "not so explicitly"? Java ht

Re: [Haskell-cafe] Formalizing lazy lists?

2005-11-19 Thread Lennart Augustsson
Greg Woodhouse wrote: Well...think about this way. The function f i = [1, 1 ..]!!i is just a constant function expressed in a complicated way. Can I algoritmically determine that f is a constant function? In general, no. Even in this case I'm pretty sure you'll need induction somewhere. I

Re: [Haskell-cafe] Infinite lists and lambda calculus

2005-11-18 Thread Lennart Augustsson
Greg Woodhouse wrote: Perhaps the issue is that the manipulations below are purely syntactic, But all the computation rules of the lambda calculus are "syntactic" in that sense. When you can prove things by symbol pushing it's the easiest way. But as Paul Hudak mentioned, there definitions tha

Re: [Haskell-cafe] Formalizing lazy lists?

2005-11-18 Thread Lennart Augustsson
Greg Woodhouse wrote: --- Lennart Augustsson <[EMAIL PROTECTED]> wrote: How about: nil = \ n c . n cons x xs = \ n c . c x xs zero = \ z s . z suc n = \ z s . s n listFromZero = Y ( \ from n . cons n (from (suc n))) zero (Untested, so I might have some mistake.) -- L

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Lennart Augustsson
Greg Woodhouse wrote: --- Paul Hudak <[EMAIL PROTECTED]> wrote: The important property of Y is this: Y f = f (Y f) Right. This is just a formal statement of the property thaat f fixex Y f. I'm with you so far. In this way you can see it as "unwinding" the function, one step at a time.

Re: [Haskell-cafe] Formalizing lazy lists?

2005-11-18 Thread Lennart Augustsson
How about: nil = \ n c . n cons x xs = \ n c . c x xs zero = \ z s . z suc n = \ z s . s n listFromZero = Y ( \ from n . cons n (from (suc n))) zero (Untested, so I might have some mistake.) -- Lennart Greg Woodhouse wrote: --- Lennart Augustsson <[EMAIL PROTECTED]> wrote:

Re: [Haskell-cafe] Formalizing lazy lists?

2005-11-18 Thread Lennart Augustsson
What do you mean by represent? It's easy enough to write down the lambda term that is the encoding of [0..]. -- Lennart Greg Woodhouse wrote: Maybe this is old hat, but the question about detecting loops in data structures got me thinking about this. I know you can encode the cons oper

Re: [Haskell-cafe] LINQ

2005-10-27 Thread Lennart Augustsson
Because mentioning FP is the kiss of death? -- Lennart PS. I can see Eric Meijer's shadow behind this. ;) Niklas Broberg wrote: Why is it that everything that OO "steals" from the functional paradigm is always marketed as something new that will revolution the way we program? Can't th

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Lennart Augustsson
Tom Hawkins wrote: Lennart Augustsson wrote: Tom Hawkins wrote: In a pure language, is it possible to detect cycles in recursive data structures? For example, is it possible to determine that "cyclic" has a loop? ... data Expr = Constant Int | Addition Expr Expr cyclic :: E

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Lennart Augustsson
Tom Hawkins wrote: In a pure language, is it possible to detect cycles in recursive data structures? For example, is it possible to determine that "cyclic" has a loop? ... data Expr = Constant Int | Addition Expr Expr cyclic :: Expr cyclic = Addition (Constant 1) cyclic Or phased different

Re: [Haskell-cafe] Nice way to calculate character frequency in a string

2005-10-25 Thread Lennart Augustsson
Sebastian Sylvan wrote: Also, you may use STArrays (I think they come in unboxed as well) for stateful code, which may be even faster (unless accumArray does some neat trick to make it O(m) where m is the number of index/value pairs). The whole idea with having accumArray as part of the Array s

Re: [Haskell-cafe] newtype is superfluous

2005-10-15 Thread Lennart Augustsson
Wolfgang Jeltsch wrote: Am Samstag, 15. Oktober 2005 08:31 schrieb Bulat Ziganshin: Hello Haskell, number of type definition statements in Haskell (data, type, newtype) is a bit too large. at least, newtype definition seems to be superfluous - it can be replaced by the same `data` definition:

Re: [Haskell-cafe] Trapped by the Monads

2005-09-20 Thread Lennart Augustsson
ing a pointer without checking for 0, and extracting the Maybe value without handling Nothing, apart from that it leads to undefined behavior in C which in fact isn't really a point against "hybrid variables". On 9/20/05, Lennart Augustsson <[EMAIL PROTECTED]> wrote: Mark C

Re: [Haskell-cafe] Trapped by the Monads

2005-09-20 Thread Lennart Augustsson
Mark Carter wrote: OTOH, I think Charles Moore is quoted as saying that if he want to add 1 to the letter A, then he didn't want the programming language to stop him. Which is quite a contrast to Haskell and its notions on safety. I'm not flamebaiting, you understand, I'm just pointing out the

Re: [Haskell-cafe] Trapped by the Monads

2005-09-20 Thread Lennart Augustsson
Mark Carter wrote: The typical example in C is: mem = malloc(1024) Malloc returns 0 to indicate that memory cannot be allocated, or a memory address if it can. The variable mem is a so-called hybrid variable; it crunches together 2 different concepts: a boolean value (could I allocate memory?)

Re: [Haskell-cafe] Re: [Haskell] pros and cons of static typing and side effects ?

2005-08-16 Thread Lennart Augustsson
Keean Schupke wrote: Other things we can do ... with dependant types we can ask the compiler to prove the correctness of sorting algorithms. If we define an ordered list tgo be one where each element must be larger than the preceding one: data OrderedIntList = Cons (a::Int) (l::OrderedList)

Re: [Haskell-cafe] matrix computations based on the GSL

2005-07-07 Thread Lennart Augustsson
David Roundy wrote: The issue is that Haskell (as far as I understand, and noone has suggested anything to the contrary) doesn't have a sufficiently powerful type system to represent matrices or vectors in a statically typed way. It would be wonderful if we could represent matrix multiplication

Re: [Haskell-cafe] type inference and named fields

2005-06-24 Thread Lennart Augustsson
Jonathan Cast wrote: No type theory (that I know of) goes beyond System F in accepting anything like foo. So, given the current state of the art, foo is unconditionally ill-typed. That could change if someone comes up with a /consistent/ type theory that accepts foo, but foo is i

Re: [Haskell-cafe] type inference and named fields

2005-06-23 Thread Lennart Augustsson
Jonathan Cast wrote: Lennart Augustsson <[EMAIL PROTECTED]> wrote: A somewhat similar problem exists even without fields: foo :: Either a b -> Either () b foo (Left _) = Left () foo x@(Right _) = x Since Haskell type checking doesn't use the information gained by pattern matc

Re: [Haskell-cafe] type inference and named fields

2005-06-23 Thread Lennart Augustsson
types. I sort-of expected that the extension to pattern matching would follow. Or is that a nice paper waiting to be written? Jacques Lennart Augustsson <[EMAIL PROTECTED]> wrote: A somewhat similar problem exists even without fields: foo :: Either a b -> Either () b foo (Left _) =

Re: [Haskell-cafe] type inference and named fields

2005-06-23 Thread Lennart Augustsson
A somewhat similar problem exists even without fields: foo :: Either a b -> Either () b foo (Left _) = Left () foo x@(Right _) = x Since Haskell type checking doesn't use the information gained by pattern matching to refine types we just have to accept that some perfectly safe programs don't typ

Re: [Haskell-cafe] (small) code review request

2005-06-16 Thread Lennart Augustsson
Radu Grigore wrote: List based solutions should also work if garbage collection is done right, e.g., fib n = fs !! n where fs = 1 : 1 : zipWith (+) fs (tail fs) So you mean my solution of the LCS problem should work in O(n) space "if garbage collection is done right"? What exactly does this

Re: [Haskell-cafe] (small) code review request

2005-06-16 Thread Lennart Augustsson
Radu Grigore wrote: Anyway, I was wondering if the O(n) space and O(n^2) time solution can be implemented in Haskell. Another way to ask this. Consider the classic fibonacci example. Can one compute the n-th fibonacci number in O(n) time and O(1) space, i.e. remember only the "last" two values du

Re: On Eq, was Re: [Haskell-cafe] When to use fancy types [Re: NumberTheory library]

2005-05-14 Thread Lennart Augustsson
Jacques Carette wrote: Anyone who thinks that +0 = -0 has never wrestled with a branch cut (and lost...). Such people have the nasty habit of also thinking that ALL functions are continuous! You might think they were constructivists or something. Why would a constructivist think that all funct

Re: [Haskell-cafe] resolving missing class instances @ compile time

2005-05-12 Thread Lennart Augustsson
Greg Buchholz wrote: Samuel Bronson wrote: The former may not be hard, but the latter would require functions with typeclass constraints on their types to be annotated in the interface file with what typeclass methods they called. Does that sound hard yet? Compared to writing the rest of the c

Re: [Haskell-cafe] When to use fancy types [Re: NumberTheory library]

2005-05-12 Thread Lennart Augustsson
Thank you for saying what I was too lazy to say myself. :) -- Lennart Jan-Willem Maessen wrote: On May 10, 2005, at 4:14 AM, Bo Herlin wrote: > Well, part of what I was doing was experimenting with what a library like > this should look like, even more than what it should do. For some re

Re: [Haskell-cafe] Squashing space leaks

2005-05-05 Thread Lennart Augustsson
Have you tried heap profiling? -- Lennart Greg Buchholz wrote: Josef Svenningsson wrote: I think the thing that really kills you is the way you shuffle around the list in the advance function. Your commented out rotations function has the same problem. Here is my attempt to solve the proble

Re: [Haskell-cafe] Newbie : What does the sequence function make?

2005-05-02 Thread Lennart Augustsson
Benjamin Franksen wrote: Another way to explain what sequence does is the following implementation, which I find a bit easier to understand for the beginner than the one given in http://www.haskell.org/onlinelibrary/standard-prelude.html : sequence [] = [] sequence m:ms = do x <- m xs <- seq

Re: [Haskell-cafe] Linux device drivers

2005-03-22 Thread Lennart Augustsson
Keean Schupke wrote: Have a look at the linux kernel IDE drivers, look for Generic IDE Chipset support That's the part I missed, you were talking about IDE chips. Yes, they have many similarities. You can probably run many of them in one of the slower modes with a common driver. But even these c

Re: [Haskell-cafe] Linux device drivers

2005-03-22 Thread Lennart Augustsson
from chipset to chipset. Keean. Lennart Augustsson wrote: But there are plenty of minor variations on how to program and initiate DMA for different devices. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/ha

Re: [Haskell-cafe] Linux device drivers

2005-03-22 Thread Lennart Augustsson
But there are plenty of minor variations on how to program and initiate DMA for different devices. -- Lennart Keean Schupke wrote: Actually with PCI chipsets, implementing a generic BusMaster DMA driver is not too hard, assuming you already have interrupts handled (and you don't want 64bit

Re: [Haskell-cafe] Point-free style

2005-02-14 Thread Lennart Augustsson
Joe Fasel argued for the inclusion of S or W in the prelude on the grounds that a complete combinator base would be "neat". But the majority of the Haskell committee didn't buy that. -- Lennart Peter G. Hancock wrote: Lennart Augustsson wrote (on Mon, 14 Feb 2005 at 14

Re: [Haskell-cafe] Point-free style

2005-02-14 Thread Lennart Augustsson
Remi Turk wrote: import Control.Monad.Reader k :: a -> b -> a k = return s :: (a -> r -> b) -> (a -> r) -> a -> b s = flip (>>=) . flip Greetings, Remi Oh, a little bit of cheating. ;) But neat. It can be done without importing anything. (Except the implicit Prelude import, of course.) -- Le

Re: [Haskell-cafe] Point-free style

2005-02-14 Thread Lennart Augustsson
Daniel Fischer wrote: And could one define \f g h x y -> f (g x) (h y) point-free? Any definition can be made point free if you have a complete combinator base at your disposal, e.g., S and K. Haskell has K (called const), but lacks S. S could be defined as spread f g x = f x (g x) Given that la

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some randomnewbiequestions

2005-01-07 Thread Lennart Augustsson
Malcolm Wallace wrote: Lennart writes: What encoding(s) did hbc allow in source files? The docs only mention unicode characters inside character & string literals. The Java encoding, i.e., \u. Well, in that case, nhc98 also supports Unicode in source files, identically to hbc. Well, you have

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some randomnewbiequestions

2005-01-07 Thread Lennart Augustsson
Simon Marlow wrote: Many years ago, hbc claimed to be the only compiler with support for this. What encoding(s) did hbc allow in source files? The docs only mention unicode characters inside character & string literals. The Java encoding, i.e., \u. -- Lennart

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some random newbiequestions

2005-01-07 Thread Lennart Augustsson
Simon Marlow wrote: Here's a summary of the state of Unicode support in GHC and other compilers. There are several aspects: - Can the Char type hold the full range of Unicode characters? This has been true in GHC for some time, and is now true in Hugs. I don't think it's true in nhc98 (plea

Re: [Haskell-cafe] coercion to Int

2004-12-31 Thread Lennart Augustsson
fnK_ :: Int -> Int fnK_ = round . sqrt . fromIntegral james pentland wrote: what coercion can i use to get the below program to compile? i see class (Real a, Fractional a) => RealFrac a where round :: (Integral b) => a -> b and class (Fractional a) => Floating a where sqrt

Re: [Haskell-cafe] Re: Non-technical Haskell question

2004-12-07 Thread Lennart Augustsson
John Goerzen wrote: On Tue, Dec 07, 2004 at 12:43:27PM +0100, Lennart Augustsson wrote: slightly slower than statically linked ones), but you still have the versioning issue. Yay! :) Dynamically linked libraries are slower than statically linked ones in just about every implementation I know of

Re: [Haskell-cafe] Re: Non-technical Haskell question

2004-12-07 Thread Lennart Augustsson
Simon Marlow wrote: Dynamic linking is (almost) a separate issue. GHC 6.4 will have some support for dynamic linking in the native code generator thanks to Wolfgang Thaller, but it needs someone to push it the final mile on x86/Linux and Windows. Dynamically linked libraries will work (albeit sli

<    1   2   3   4   5   6   7   >