Re: [Haskell] Image manipulation

2007-10-31 Thread Bjorn Lisper
Jerzy Karczmarczuk: >Dan Piponi adds to a short exchange: > >> jerzy.karczmarczuk: >>> [iso-8859-1] Bj�rn Wikstr�m writes: >>> >>> > Hi! I have lots and lots of images (jpegs) that I would like to manipulate >>> > and shrink (in size). They are around 5 Mb big, so I thought this would >>> > b

Re: [Haskell] Compilation of big, computed tables

2006-02-23 Thread Bjorn Lisper
Chris Kuklewicz: >Stefan Karrmann wrote: >> Dear all, >> >> can ghc compile huge tables into efficient code if they are constant at >> compile time? >> >> Two examples may clearify the question: >> >> big1 :: UArray Int Char >> big1 = array (0,1000) $! map (\i -> (i,toEnum i)) [0..1000] >> >>

Re: [Haskell] why don't we have const Ptrs?

2005-11-02 Thread Bjorn Lisper
Hi, Annotated type systems have been around for some time in static program analysis. I think this is what you want. For instance, you can design such a system to record possible side effects from a function call, as annotations on the type of the function. See the book "Principles of Program Ana

Re: [Haskell] getArgs, maxBound, float division: pure functions?

2005-10-12 Thread Bjorn Lisper
John Meacham: >On Wed, Oct 12, 2005 at 12:05:39AM -0400, David Menendez wrote: >> In principle, you could use seperate types to distinguish floats with >> different rounding modes, but I imagine this would be difficult or >> annoying to implement. > >I think it would make more sense to have differe

Re: [Haskell] Mixing monadic and non-monadic functions

2005-09-14 Thread Bjorn Lisper
Ben Rudiak-Gould: >Frederik Eaton wrote: >> I want the type system to be able to do "automatic lifting" of monads, >> i.e., since [] is a monad, I should be able to write the following: >> >> [1,2]+[3,4] >> >> and have it interpreted as "do {a<-[1,2]; b<-[3,4]; return (a+b)}". > >The main problem

Re: [Haskell] Typing in haskell and mathematics

2005-01-31 Thread Bjorn Lisper
Jacques Carette: >Yes, I am aware that this untypeable in Haskell, because polymorphism is >straight-jacketed by structural rules. But >in mathematics, it is convenient and extremely common to: >1) look at the type a -> b as being a *subtype* of b (though I have never seen >it phrased that

Re: [Haskell] Implicit parallel functional programming

2005-01-20 Thread Bjorn Lisper
Keean Schupke: >>A guess is that the first generation will support a shared memory model much >>like SMP:s of today (shared main memory with on-chip cache(s), or some other >>kind of local memory (-ies)). Here, I think implicit parallelism in >>functional languages can be a win in some situations.

Re: [Haskell] Implicit parallel functional programming

2005-01-20 Thread Bjorn Lisper
I'd like to add my two cents worth in this debate... I think the original poster considered the standard multicore processors soon to come, and which can be expected to eventually overtake the processor market. The answer relies a lot on what shape these processors will have: A guess is that the

Re: [Haskell] 2-D Plots, graphical representation of massive data

2004-08-27 Thread Bjorn Lisper
Jerzy Karczmarczuk: >Jacques Carette wrote: > >> John Meacham <[EMAIL PROTECTED]> wrote: >> >>> What would be cooler (IMHO) would be brining all of matlabs >>> functionality into haskell via haskell libraries so one may use 'ghci' >>> sort of as one uses matlab, but with the advantages haskell brin

Re: [Haskell] Eliminating Array Bound Checking through Non-dependent types

2004-08-06 Thread Bjorn Lisper
( A really interesting post on static elimination of array bounds checking by Oleg...) Some questions and suggestions: What is the relation to the sized types by Lars Pareto and John Hughes? What is the relation to classical range analyses for (e.g.) array index expressions, which have been know

Re: [Haskell] insufficiently [EMAIL PROTECTED] -- more counterintuitive stuff

2004-03-30 Thread Bjorn Lisper
Andrew Bromage: >Pattern matching on the LHS of a function definitions looks, for all the >world, like a set of rewrite rules. That's because, in some sense, they >are. > >In this definition: > >f (x:xs) = 1 + f xs >f [] = [] > >Intuitively, the first rule should only "fire" if the express

Re: [Haskell] Programming language shootout (completing the Haskell entry)

2004-03-29 Thread Bjorn Lisper
>From: John Hughes <[EMAIL PROTECTED]> >Actually the cache behaviour of code generated by GHC isn't at all bad. >I know because I ran a student project a couple of years ago to >implement cache-friendly optimisations. The first thing they did was >cache profiling of some benchmarks, and to our s

Re: [Haskell] Making a spreadsheet with Haskell

2004-02-13 Thread Bjorn Lisper
> Hi, I would like to know how can I make a spreadsheet using Haskell > (something like Excel, a very-reduced version, of course) > Do I need any kind of special library? How can I make the interface so the > user can introduce data, select data and so on? > Thanks for your help. > Miren Cob Isa

Re: palm?

2003-03-10 Thread Bjorn Lisper
>Just a side remark. >I wonder whether the byte-code approach is the best possible solution >taking into account the overload of the decoder. Why not threaded code? >The FORTH (and similar) experience, PostScript implementations, etc. >show that this paradigm may be more interesting. Anyway, when y

Re: palm?

2003-03-10 Thread Bjorn Lisper
M. Parker: >What about a port to Windows CE (i.e., for Pocket PC's). Or even better yet, >hugs for Pocket PC! > >-Matt There is an interesting research question in here: how to design "lean" implementations of lazy functional languages so they can run on small handheld and embedded systems with r

Re: Arrays vs Lists and Specialization

2003-01-22 Thread Bjorn Lisper
Matthew Donadio: >| Many spectral estimation routines are defined in terms of special >| matrices (ie, Toeplitz, etc). Arrays defined recursively by list >| comprehensions make it easy to implement algorithms like >Levinson-Durbin >| recursion, and they look very similar to the mathematical defini

Re: What does FP do well? (was How to get ...)

2002-05-17 Thread Bjorn Lisper
Jerzy: >Me: >> ...sometimes the length of a list being returned from a >> function can be a simple function of the function arguments (or the sizes of >> the arguments), think of map for instance. In such cases, a static program >> analysis can sometimes find the length function. If we know thee f

Re: What does FP do well? (was How to get functional software engineering experience?)

2002-05-16 Thread Bjorn Lisper
Karl-Filip: >But what I really meant is, if I may rephrase it, that imperative >programs might often be both faster and harder to write because they >embed more information about the abblication domain. That is, if you >code in C and want an array, you must specify its size, so you have to >thi

Re: Isn't this tail recursive?

2002-03-12 Thread Bjorn Lisper
Hal Daume III: >Here's the basic idea. Suppose we have the function: > >> sum [] acc = acc >> sum (x:xs) acc = sum xs (acc+x) > >This is tail recursive, but not strict in the accumulator argument. ... Just a nitpick here. sum is indeed strict in its second argument (given that (+) is strict in i

Re: ideas for compiler project

2002-01-24 Thread Bjorn Lisper
Simon: >Lots of people have observed that Haskell might be a good "scripting >language" for numerical computation. In complicated numerical >applications, the program may spend most of its time in (say) matrix >multiply, which constitutes a tiny fraction of the code for the >application. So write

Re: Strange error in show for datatype

2001-10-05 Thread Bjorn Lisper
Hi again, My question about my student's problem surely stirred an interesting and clarifying discussion. Still, I have a question. Reconsider the example. There's a data type data LispList t = Atom t | LispList [LispList t] | Str [Char] and an instance declaration instance Show t => Show (L

Strange error in show for datatype

2001-10-03 Thread Bjorn Lisper
Hi, For a change, a teacher asking for help on behalf of a student I have a student who wants to emulate S-expressions of Lisp in Haskell. He came up with the following data type: data LispList t = Atom t | LispList [LispList t] | Str [Char] This works just fine. He then wanted to make it

Re: Revamping the numeric classes

2001-02-13 Thread Bjorn Lisper
Marcin 'Qrczak' Kowalczyk: >Me: >> Functions themselves are never lifted. They just appear to be lifted >> when applied to arguments of certain types, and then the function >> application is always statically resolved into an expression where >> the function has its original type. >This does not

Re: Revamping the numeric classes

2001-02-11 Thread Bjorn Lisper
Marcin Kowalczyk: >>Me: >> No, the transformation is a single step procedure where a term >> is transformed into a typeable term (if possible) with a minimal >> amount of lifting. You don't compose transformations. >So functions implicitly lifted can't be used in the same ways as >functions origi

Re: Types from values using existential types?

2001-02-10 Thread Bjorn Lisper
>I recently had an idea to allow one to create types from values. This >would have many uses in Haskell; e.g., it would be very nice to have a >type of nxn matrices for n that are not necessarily statically >determined. (It is easy to create a type of matrices and check that >the sizes are compa

Re: Revamping the numeric classes

2001-02-09 Thread Bjorn Lisper
>> >I see. So you can transform arbitrary function of type a->b->c >> >to a function of type [a]->b->[c], by applying >> >\f x y -> map (\z -> f z y) x >> >and similarly a->b->c to a->[b]->[c]. But then there are two ways of >> >transforming a->b->c to [a]->[b]->[[c] > >> There should be no tr

Re: Revamping the numeric classes

2001-02-08 Thread Bjorn Lisper
>I see. So you can transform arbitrary function of type a->b->c >to a function of type [a]->b->[c], by applying >\f x y -> map (\z -> f z y) x >and similarly a->b->c to a->[b]->[c]. But then there are two ways of >transforming a->b->c to [a]->[b]->[[c]] and the order of applying the >former tr

Re: Revamping the numeric classes

2001-02-08 Thread Bjorn Lisper
>> It is quite similar in spirit to the concept of principal type in >> Hindley-Milner type systems. An expression can have many types but >> only one "best" (most general) type in that system. >Now, I'm not any kind of expert on this, but isn't the most general >HM type one that encompasses the

Re: Revamping the numeric classes

2001-02-08 Thread Bjorn Lisper
>> >Also, what is the inferred type of, for example >> >f x y = x + length y >> >? It can be >> >Int -> [a] -> Int >> >[Int] -> [a] -> [Int] >> >and neither is more general than the other. And this is a simple >> >function. >> >> Int -> [a] -> Int, since this is the type it will get i

Re: Revamping the numeric classes

2001-02-07 Thread Bjorn Lisper
Marcin Kowalczyk: >Me: >> A natural principle to adopt is that an already typeable expression should >> not be transformed. This will for instance resolve the ambiguity in the list >> of list example: if l :: [[a]] then length l is already well-typed and >> should not be transformed into map lengt

Re: Revamping the numeric classes

2001-02-07 Thread Bjorn Lisper
Marcin 'Qrczak' Kowalczyk: >>Me: >> I'd like to point out the connection between the use of +, - on vector >> spaces and * for scaling with features in some data parallel languages. In >> these languages, writing a + b where a and b are arrays of numerics is >> interpreted as elementwise addition

Re: Revamping the numeric classes

2001-02-07 Thread Bjorn Lisper
Dylan Thurston: >Andreas Gruenbacher: >> It may be the case that using (*) for scaling too is a generally bad >> idea... >It may not be type sound to have the same operation, but there should >be some standard operation for scaling. (Probably you need >multi-parameter type classes for this.) I'

Re: Specifications of 'any', 'all', 'findIndices'

2001-01-23 Thread Bjorn Lisper
>Pardon? >map is data parallel. foldr not so obviously... Sorry, a slip on my behalf: foldr in general is not data parallel, but if the function being folded with is associative then foldr can be implemented by a parallel (balanced binary-tree) reduction in time O(log n), where n is the length of

Re: Specifications of 'any', 'all', 'findIndices'

2001-01-23 Thread Bjorn Lisper
Koen: >The definitions in the Haskell report are a *specification*, >not an implementation. It probably depends on the compiler >which particular implementation runs faster. >Therefore, the Haskell report provides a clear (yes, this is >debatable) *possible* implementation, and the compiler >writ

Re: Higher-order function application

2000-08-23 Thread Bjorn Lisper
Tim Sweeney: >Is this "higher order function application" a useful notion, and does any >research exist on the topic? The answer to the first question is "yes, when it matches the intuition of the programmer". Your two first examples: >cos+sin-- intent: \x->((cos x)+(sin x)) >cos

Re: What happened to the GRIN project?

2000-06-19 Thread Bjorn Lisper
> 1) are anyone pursuing this line of work, and >Sadly, Urban left us for industry (Carlstedt Research and Technology), where >Thomas Johnsson is also on sabbatical at the moment. So nobody here is >pursuing this at the moment. > 2) is the software available? >Ask Urban: [EMAIL

Re: == and hyperstrictness

2000-03-22 Thread Bjorn Lisper
Me: >> I think the cleanest solution is to add a method "hseq" to the Eval >> class, which is similar to seq but evaluates its first argument >> hyperstrictly before returning its second. Marcin 'Qrczak' Kowalczyk: >You mean "implicit Eval"? Then I would certainly not call this solution >"clean".

Re: == and hyperstrictness

2000-03-22 Thread Bjorn Lisper
>Suppose Sven implements his `len' function as above, and furthermore >implements a library which depends on this function being hyperstrict. >Suppose next that I implement an instance of `==' that returns `True' without >evaluating the arguments, and then finally suppose a third programmer called

Re: definition domain extension proposal

2000-01-31 Thread Bjorn Lisper
Sergey: >To separate a sublanguage of Haskell given by the corresponding >compilation key (say, -domExt ) or, maybe, by the compiler pragma. >This sublanguage allows the compiler to replace any function f with >the function f' being the extension for f. This was discussed on the list a w

Re: fixing typos in Haskell-98

2000-01-24 Thread Bjorn Lisper
> Take and drop > [..] > I can see three alternatives: > > (A) Make them defined for any n. If n < 0, do something reasonable: > take: give empty list > drop: give whole list > > (B) Make them defined for n > length xs, but fail for n < 0. > > (C) Status quo > > PROPOSAL: Use al

Re: What is a functional language?

1999-09-28 Thread Bjorn Lisper
Me: >> Yes, it makes a lot of sense. The parallel or above is a classical example >> of a function for which there exists no semantically correct sequential >> evaluation order of its arguments (i.e., an evaluation order where an >> argument is evaluated in full before the evaluation of the next a

Re: What is a functional language?

1999-09-27 Thread Bjorn Lisper
>On Mon 27 Sep, Bjorn Lisper (i.e., me) wrote: >> For instance, a logical or which is strict in both arguments will >> be commutative and associative, while a nonstrict or with a left-to-right >> evaluation order of its arguments will be non-commutative but still >>

Re: What is a functional language?

1999-09-27 Thread Bjorn Lisper
Adrian Hey <[EMAIL PROTECTED]>: >The issue I'm thinking about is equational reasoning and program >transformation. For a lazy (non-strict) language, transformations >are constrained so that a function definition which is non-strict >in an argument is never transformed into one which is strict in t

Re: Non-strictness vs. laziness (was RE: Sisal)

1999-09-24 Thread Bjorn Lisper
>Joe Fasel wrote: >> Actually, I think we were originally thinking of laziness, rather >> than nonstrictness, and weren't considering languages like Id as >> part of our domain, but Arvind and Nikhil (quite correctly) convinced >> us that the semantic distinction of strictness versus nonstrictness

Re: Cryptarithm solver - Haskell vs. C++

1999-09-22 Thread Bjorn Lisper
"Manuel M. T. Chakravarty" <[EMAIL PROTECTED]>: >* While Sisal is arguably nice than Fortran, it doesn't > really provide a new killer feature - rewriting all this > Fortran code, just for getting nice programs is maybe not > enough of an incentive. As I remember it, a main argument for Sisal

Re: Cryptarithm solver - Haskell vs. C++

1999-09-22 Thread Bjorn Lisper
"D. Tweed" <[EMAIL PROTECTED]>: >I'm quite open to arguments that maybe you can't >make a functional language that's as nice as Haskell (features like lazy >evaluation, nice type classes, etc) that's also able to `really hammer >until it's totally flat' functional code that implements heavily nume

Re: more on Rules

1999-05-07 Thread Bjorn Lisper
gid as the one that actually is implemented by the code. The problem we had here earlier, about reordering reductions where the operations are only "almost AC" (e.g., floating-point arithmetic), is similar. Often one wouldn't care about the numerical variations resulting from different reduction orders, but sometimes they could matter. Bjorn Lisper

Re: non-linear patterns

1999-05-05 Thread Bjorn Lisper
may be nonconfluent. So Haskell's pattern matching is not precisely the same as term rewriting, but anyway. Bjorn Lisper

Re: STL Like Library For Haskell

1999-04-29 Thread Bjorn Lisper
rings fall within the requirements? Yes (use lexicographic order), but we don't have them for now. Bjorn Lisper

Re: STL Like Library For Haskell

1999-04-29 Thread Bjorn Lisper
enumerable set. It would not be very sensible to, for instance, try to impose a total order on a set of functions. A total order of the objects representing the functions would of course be possible and could be used to have the balanced trees, but it would not be possible to, say, have a well-defined fold over that kind of set (or any indexed structure using this set as index set). Bjorn Lisper