Duncan Coutts wrote:
So it's easy if you link the system using ghc. If you want to link it
all using gcc instead, yeah, that's a bit harder. You can see most of
the flags ghc passes to gcc as they're just in the package configuration
for the rts and base packages (ghc-pkg display rts /
Matthew Brecknell wrote:
Jan-Willem Maessen:
Interestingly, in this particular case what we obtain is isomorphic
to constructing and reversing a list.
Jan-Willem's observation also hints at some interesting performance
characteristics of difference lists. It's well known that difference
Hi, first time list poster :)
I've searched around a bit but haven't been able to find any examples of
this. I want to be able to parse a language (such as Haskell, Python)
which has only EOL as the 'statement' separator and has indentation
levels to indicate block structure. Whilst doing this I
[EMAIL PROTECTED] wrote:
Quoting apfelmus [EMAIL PROTECTED]:
You mean O(k * log n + n) of course.
Erm, yes. You can do it in an imperative language by building a heap
in O(n) time followed by removing k elements, in O(k log n) time.
Ah, sorry, there are indeed to variants not comparable
Hello kynn,
Thursday, April 12, 2007, 7:10:56 AM, you wrote:
rather pragmatic. I have not been able to find enough support in Haskell
for everyday tasks (e.g. read a stream from a socket; parse it into a simple
data structure; process the data in the structure; print out the results to
a
Hi all,
for my current project I need a monad that is an instance of MonadIO,
MonadReader, MonadWriter, MonadState, and MonadError. I see two ways for
defining such a monad using the mtl.
1) type MyMonad = ErrorT E (RWST R W S IO)
and
2) type MyMonad = RWST R W S (ErrorT E IO)
I can't
You may be missing a few recursive calls there :-)
Indeed.
I'm confused.
Is this a legitimate stable quicksort, or not? (My guess is, it is
indeed legit as written.)
This was also the first I have heard of stability as a sort property.
http://perldoc.perl.org/sort.html may shed some light
And for reference, here is again stefan's stable quicksort from his
earlier post.
sort [] = []
sort l@(x:_) = filter (x) l ++ filter (==x) l ++ filter (x) l
(A stable quicksort, btw)
This is the code whose legitimacy I am requesting confirmation of.
2007/4/13, Thomas Hartman [EMAIL
Martin Huschenbett wrote:
Hi all,
for my current project I need a monad that is an instance of MonadIO,
MonadReader, MonadWriter, MonadState, and MonadError. I see two ways for
defining such a monad using the mtl.
1) type MyMonad = ErrorT E (RWST R W S IO)
and
2) type MyMonad = RWST
Trying to understand this better I also came across
http://groups.google.de/group/fa.haskell/browse_thread/thread/1345c49faff85926/8f675bd2aeaa02ba?lnk=stq=%22I+assume+that+you+want+to+find+the+k%27th+smallest+element%22rnum=1hl=en#8f675bd2aeaa02ba
where apfulmus gives an implementation of
Rereading this, I see in fact apfelmus explains this is
O(n + k*log n) for the first k elements, which this discussion also
maintains is the best case. So, there's no discrepancy.
I think this is a very valuable post to read for the explanation.
2007/4/13, Thomas Hartman [EMAIL PROTECTED]:
For various reasons I had a similar problem that I solved iteratively
simply with a sorted list of the actual best elements.
The only particular things were
1. keep element count (to easily know if the element should be inserted
in any case)
2. keep the list in reverse order to have the
On 4/11/07, Chris Kuklewicz [EMAIL PROTECTED] wrote:
...
My previous weave, uses composition of (xs:) thunks instead of pairs:
weave :: [[a]] - [a]
weave [] = []
weave xss = helper id xss
where helper :: ([[a]] - [[a]]) - [[a]] - [a]
helper _rest ([]:_xss) = [] -- done
G'day all.
Quoting Thomas Hartman [EMAIL PROTECTED]:
Does that mean you can have the k minima in O(n) time, where n is
length of list, which would seem to be an improvement?
It's worth considering what the theoretical minimum is.
You have n elements, and you need to locate a specific
Hello everybody,
I would like to start a discussion on how to generate
best-practice Haskell code from a model, e.g. from
EMF.
It seems to be very difficult and unconvenient to simulate
OOP with Haskell (as described in the paper Object-oriented
style overloading for Haskell). However, I think
The fun never ends...
Bas van Dijk wrote:
On 4/11/07, Chris Kuklewicz [EMAIL PROTECTED] wrote:
...
My previous weave, uses composition of (xs:) thunks instead of pairs:
weave :: [[a]] - [a]
weave [] = []
weave xss = helper id xss
where helper :: ([[a]] - [[a]]) - [[a]] - [a]
It seems that what you want is a standalone .a file that you can then link into
other programs without any special options. In principle this should be
possible: you just need to include .o files for the RTS and libraries, and
fortunately we already have those (HSrts.o, HSbase.o etc.) because
Answering my own plea for help, I now have the following, which seems
neater to me.
company_to_companyfile = [(ibm,data/ibm.dat),(cisco,data/cisco.dat)]
displaymode_to_modestring = [(points, using 1:2 with linespoints),
(candles,using 1:($2+$3+$4+$5)/4:4:3 with yerrorbars)]
Hello,
My Hugs tells me this:
Prelude let sort [] = []; sort l@(x:_) = filter (x) l ++ filter (==x) l ++
filter (x) l in sort [1,3,2]
[1,3,2]
Prelude
So, no, this is not a working sorting function. Inserting the few missing
recursive calls:
Prelude let sort [] = []; sort l@(x:_) = sort (
And this mess can be simplified further by something like
financial_output_wrapper company displaymode startDate endDate =
do
let maybeCompanyFile = lookup company company_to_companyfile
validate_arg company company maybeCompanyFile
validate_arg argname arg maybeTransformedArg
Answering my own plea for help, I now have the following, which seems
neater to me.
checking Maybes is best done in the Maybe Monad, or if you need specific error
messages, using maybe. that, in turn can be abstracted out into a lookup with error
message. once the checking is done in the
On Fri, Apr 13, 2007 at 07:32:20AM -0400, [EMAIL PROTECTED] wrote:
Quoting Thomas Hartman [EMAIL PROTECTED]:
Does that mean you can have the k minima in O(n) time, where n is
length of list, which would seem to be an improvement?
It's worth considering what the theoretical minimum is.
While we're on the topic, does anyone know if there exists a similarly
simple solution like the (last) section Using both Python Haskell
with ctypes at
http://wiki.python.org/moin/PythonVsHaskell
that works on Linux to easily link Haskell libraries/functions into Python?
Cheers,
Jason
On
On Apr 12, 2007, at 9:39 PM, Matthew Brecknell wrote:
Jan-Willem Maessen:
Interestingly, in this particular case what we obtain is isomorphic
to constructing and reversing a list.
Jan-Willem's observation also hints at some interesting performance
characteristics of difference lists. It's
On 4/13/07, Steffen Mazanek [EMAIL PROTECTED] wrote:
Hello everybody,
I would like to start a discussion on how to generate
best-practice Haskell code from a model, e.g. from
EMF.
I started learning Haskell precisely to solve problems like this. But, once
I got into it, I realized that
Hello,
I defined a newtype like this (the ()s will be replace with
something more useful in the future):
newtype DryRunIO a = DryRunIO { runDryRunIO :: RWST Bool () () IO a }
deriving (Monad, MonadIO, MonadError IOError, MonadFix, Functor,
MonadReader Bool, MonadWriter (), MonadState ())
financial_script = gnuplot_timeseries_settings ++ \n
++ plot [\ ++ startDate ++ \:\ ++ endDate ++ \]
++ ' ++ companyFile ++ ' ++ modeString
++ title \ ++ company ++ ++ titleEnd ++ \
Also note the existence of Text.Printf if you like
Chris Kuklewicz schrieb:
Martin Huschenbett wrote:
1) type MyMonad = ErrorT E (RWST R W S IO)
2) type MyMonad = RWST R W S (ErrorT E IO)
So (1) gives (Left e,s,w) or (Right a,s,w)
and (2) gives (Left e) or (Right (a,s,w))
Due to this fact i decided to use (1). If the operation fails and I
Brian, but don't you think that you have to write a lot
of boilerplate code in Haskell?
Second, if Haskell should be more successful in the
real world there has to be a way of demonstrating
basic ideas of a big program to customers. How
would you do this? Everybody knows UML class
diagrams, for
On 4/13/07, Ian Lynagh [EMAIL PROTECTED] wrote:
Tuple each element with its position: O(n)
Find kth smallest element in linear time, as per [1]: O(n)
Filter list for elements = kth smallest: O(n)
Sort filtered list by position: O(k log k)
map
In the GHC docs:
http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/sec-ffi-ghc.html#using-own-main
There can be multiple calls to hs_init(), but each one should be
matched by one (and only one) call to hs_exit()[8].
What exactly happens with nested calls? Is there only one runtime
jasonm wrote:
While we're on the topic, does anyone know if there exists a similarly
simple solution like the (last) section Using both Python Haskell
with ctypes at
http://wiki.python.org/moin/PythonVsHaskell
that works on Linux to easily link Haskell libraries/functions into
Python?
Hi
Just to say, I agree with Brian totally! I've been (violently and
forcefully) exposed to MOF tools in the past, and at every turn my
thought was the Haskell would be clearer, shorter and executable!
Brian, but don't you think that you have to write a lot
of boilerplate code in Haskell?
Dan Weston wrote:
In the GHC docs:
http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/sec-ffi-ghc.html#using-own-main
There can be multiple calls to hs_init(), but each one should be
matched by one (and only one) call to hs_exit()[8].
What exactly happens with nested calls? Is
Hi Neil,
Just to say, I agree with Brian totally! I've been (violently and
forcefully) exposed to MOF tools in the past, and at every turn my
thought was the Haskell would be clearer, shorter and executable!
This is true only for programming in the small, isn't it?
Furthermore, from my point
On 4/13/07, Neil Mitchell [EMAIL PROTECTED] wrote:
Second, if Haskell should be more successful in the
real world there has to be a way of demonstrating
basic ideas of a big program to customers. How
would you do this? Everybody knows UML class
diagrams, for example. In contrast, nobody
Hi! I'm trying to use a partial monadic parser with Happy (using
%partial %monad and %lexer). The problem is that the parser function
always seems to eat up one token beyond the matched sequence regardless of
what I do. So I can't, for instance, call the parser multiple times to
parse a
I was trying to speed up a program that I wrote and so I thought
about using multiple threads.
I have a quite easy parallel program and I did the following
do
subRes - MVar.newMVar []
putStrLn starting threads
subV - flip mapM [0 .. (nThreads - 1)] $
( \i - do
On Sat, Apr 14, 2007 at 12:27:10AM +0200, Fawzi Mohamed wrote:
I was trying to speed up a program that I wrote and so I thought
about using multiple threads.
I have a quite easy parallel program and I did the following
do
subRes - MVar.newMVar []
putStrLn starting threads
More info: I managed to do a hack that works around it, but it is
clearly not acceptable. Part of the Haskell code generated by Happy
contains this:
---
-- Accepting the parse
-- If the current token is 0#, it means
This is true only for programming in the small, isn't it?
my favourite opinion on that subject was expressed, back in 1984, in
Burstall, Lampson
A kernel language for modules and abstract data types
http://www.hpl.hp.com/techreports/Compaq-DEC/SRC-RR-1.html
paraphrasing:
Il giorno Apr 14, 2007, alle ore 12:33 AM, Stefan O'Rear ha scritto:
On Sat, Apr 14, 2007 at 12:27:10AM +0200, Fawzi Mohamed wrote:
I was trying to speed up a program that I wrote and so I thought
about using multiple threads.
I have a quite easy parallel program and I did the following
do
On Sat, Apr 14, 2007 at 01:31:58AM +0200, Fawzi Mohamed wrote:
Il giorno Apr 14, 2007, alle ore 12:33 AM, Stefan O'Rear ha scritto:
On Sat, Apr 14, 2007 at 12:27:10AM +0200, Fawzi Mohamed wrote:
I was trying to speed up a program that I wrote and so I thought
about using multiple threads.
Stefan O'Rear wrote:
On Thu, Apr 12, 2007 at 01:04:13PM +0100, Joel Reymont wrote:
Folks,
The ghc/compiler/typecheck directory holds a rather large body of
code and quick browsing through did not produce any insight.
How do you implement type checking in haskell?
Assume I have an Expr
Jan-Willem Maessen wrote:
On Apr 12, 2007, at 9:39 PM, Matthew Brecknell wrote:
Jan-Willem Maessen:
Interestingly, in this particular case what we obtain is isomorphic
to constructing and reversing a list.
Jan-Willem's observation also hints at some interesting performance
characteristics
45 matches
Mail list logo