I am playing with using SYB to make generic indexed collections. The
current code is this:
data Syb = Syb [Dynamic] -- list of [Map val (Set a)]
empty item = Syb $ gmapQ (toDyn . emp item) item
where
emp::x-y-Map.Map y (Set.Set x)
emp x y = Map.empty
insert x
A conversation on #haskell just showed that it's quite hard to explain
(at least it is for me) to people attached to tail recursion why that is
a red herring in Haskell.
I had a poke around the wiki and couldn't see a page which explains it
clearly. In fact
Hi all,
I'm searching for a tool which generates a module dependency graph (a
graphviz backend would be more than enough).
Does anybody know a tool with such functionality?
Cheers,
Fons
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Stefan O'Rear wrote:
On Thu, May 17, 2007 at 11:22:34AM +0100, Simon Marlow wrote:
sequence still isn't tail-recursive, although sequence_ is. If you want a
tail-recursive sequence, the only way to do it is like this:
sequence' :: [IO a] - IO [a]
sequence' ms = do
let as = map
| and (at worst) are evil. These people are quite simply wrong and
| should be ignored :-)
|
| Adrian Hey is not only wrong, but actually evil. He should be ignored. :-)
|
| I am right, I might well be evil, and if past experience is anything to
| go by I already know that I will be ignored.
iskaldur wrote:
I'm trying to learn to use the Writer Monad, but I'm having trouble with the
following very simple program:
import Control.Monad.Writer
foo :: Writer String Int
foo = tell hello
Basically, I was trying to figure out the 'tell' function, so I want foo to
return ((), hello).
I'm trying to learn to use the Writer Monad, but I'm having trouble with the
following very simple program:
import Control.Monad.Writer
foo :: Writer String Int
foo = tell hello
Basically, I was trying to figure out the 'tell' function, so I want foo to
return ((), hello).
But I get this
On Wed, 16 May 2007, Evan Laforge wrote:
I think that in every particular case you have to find out how to avoid
'reverse'. Especially if you have two 'reverse's like in
reverse . dropWhile p . reverse
there are more efficient solutions.
Just from curiosity, what *is* an efficient
On Thu, 17 May 2007, Jules Bean wrote:
Eric wrote:
H|i,
Does anyone know of a simple and straightforward way to use global
variables in Haskell?
(Perhaps annoyingly) the answer to this question, like so many other
questions on this list, is a question. What are you trying to do?.
On May 18, 2007, at 7:32 , iskaldur wrote:
import Control.Monad.Writer
foo :: Writer String Int
foo = tell hello
foo = tell hello return 1 -- or whatever
You declared it to return Int, you should probably produce an Int
somewhere
--
brandon s. allbery
PR Stanley [EMAIL PROTECTED] wrote:
No, Mr. smarty pants, I can't. I'll leave you to work out why I rely
on a scanner and an OCR engine for reading printed materials. *smile*
Ah. Well, given your original question (why does this code not work?)
it was probably a reasonable assumption that
[I agree with your points, but...]
Adrian Hey wrote:
I've pretty much convinced it's wrong. There should be one and only
one main from which all subsequent IO activity derives. But creating
internal state in the form of mutable data structures is not an IO
activity. It just so happens that at
Jules Bean wrote:
main = do
sockstate - initSocks
graphstate - initGraphics
...
disposeGraphics graphstate
disposeSocks sockstate
exit
Voila. Mutable state which persists for our entire program.
Arguably it's a pain passing around the state explicitly. Alternatively,
you can
On Fri, 18 May 2007 01:52:11 -0700, Jules Bean [EMAIL PROTECTED]
wrote:
A conversation on #haskell just showed that it's quite hard to explain
(at least it is for me) to people attached to tail recursion why that is
a red herring in Haskell.
If someone has the energy and the clarity to
Dear Sir,
At the risk of seeming a little pedantic let me remind you that
Andrew's remark was in reply to the following message:
start message
Well, actually, this was scanned from a book but the OCR process
wasn't 100% effective. So, I was hoping the list would easily
identify and replace
Simon Peyton-Jones wrote:
For example, I was looking back at your ACIO mail a couple of months ago,
when I was thinking about concurrency.
Actually, this is Ian Starks proposal..
http://www.haskell.org/pipermail/haskell-cafe/2004-November/007664.html
..but is one with which I agree. I just
Hi
Can anybody tell me what complexity class nub belongs to?
nub requires Eq and not Ord, therefore you can prove that _any_ nub,
no matter how good it is, must be O(n^2).
Thanks
Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Greetings.
Can anybody tell me what complexity class nub belongs to?
(The implementation in the Language Report appears to have n^2
complexity. Do the actual implementations out there follow?)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Take a look to HaSlicer
(http://labdotnet.di.uminho.pt/HaSlicer/HaSlicer.aspx).
It can do that.
Best
Miguel Vilaça
-Mensagem original-
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Em nome de Alfonso Acosta
Enviada: sexta-feira, 18 de Maio de 2007 12:11
Para: Haskell-cafe
Assunto:
OK, so I was hanging out on this newsgroup I often lurk. And we're
having a discussion. And I'm all like Haskell is the greatest! And
they're all like nah, Haskell sux. And this one dude goes hey, look
at this C++ code. How do you do that in Haskell? And three other people
look at this C++ and
Andrew Coppin wrote:
It occurs to me that if you want a sorted list of only unique
elements, it would seem (to me) to be efficient to do the sorting and
the uniquing at the same time. Does any library function do this? (I
imagine it wouldn't be hard to write it yourself...)
Yes, although it
On 18/05/07, Albert Y. C. Lai [EMAIL PROTECTED] wrote:
Lazy evaluation says, to evaluate x, call f first, then x is the last
call.
x may be the last to be evaluated, but you still have to pass through
f's call context 'on the way out'. For example, suppose in the
expression 'f x y' you have f
Hello,
Andre Nathan schrieb:
so I'm wondering what else I need to do for the do
notation to work.
import Prelude hiding ((=), return)
You explicitly ask for the well-known and standard functions = and
return to be hidden away, because you want to define your own versions.
p :: Parser
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Adrian Hey wrote:
Furthermore, if it is going to take this state handle as an explicit
argument then you need to provide some way for users to get this
state handle. This could be by..
1 - Making it an argument of main.
2 - Exposing a
On Fri, 2007-05-18 at 22:32 +0200, Tillmann Rendel wrote:
[snip]
Now you should be able to use do notation with your own Parser type.
Thanks! Monads and instances weren't mentioned until that point, so I
was assuming that all that was needed for the do notation to work was
having (=) and return
On Thu, May 17, 2007 at 07:25:03PM +0100, Adrian Hey wrote:
The above hack is not actually Haskell. It's a hack, and it depends on
the particular implementation characteristics of GHC. It is not
unreasonable to imagine that a future GHC might contain different
compilation techniques (I
On Thu, May 17, 2007 at 11:00:18PM +0100, Jules Bean wrote:
I'm not sure that's quite to the point. Clearly we can set up state at
the top of our main action:
main = do
sockstate - initSocks
graphstate - initGraphics
...
disposeGraphics graphstate
disposeSocks sockstate
If you allow me to play Devil's advocate for a moment...just don't let
this guy ask you how long the Haskell version takes.
In fact, you can borrow a trick from the C++ version. Try this instead:
import Data.Set
main = interact $ unlines . toList . fromList . words
Assuming Data.Set is
OK, I looked up group and didn't see any Ord constraint analog. I give
up. What is the common idiom? I was stupidly using nub even though I
already have an Ord constraint. I have rewritten it to:
unique :: Ord a = [a] - [a]
unique (x:y:z) = (if x y then (x:) else id) (unique (y:z))
unique xyz
How does the type of fromList get determined? And is Data.Set.toList the
same as Data.Set.toAscList?
Dan Piponi wrote:
If you allow me to play Devil's advocate for a moment...just don't let
this guy ask you how long the Haskell version takes.
In fact, you can borrow a trick from the C++
group collects equal elements in sublists. Thus, unique can be implemented
as:
unique = map head . group
i.e. taking the first of each group of equal elements.
(Yet) another way of doing this, is a modified quicksort:
qsort [] = []
qsort (x:xs) = qsort (filter (x) xs) ++ [x] ++ qsort (filter
On Fri, May 18, 2007 at 02:39:48AM -0400, Alex Jacobson wrote:
I am playing with using SYB to make generic indexed collections. The
current code is this:
data Syb = Syb [Dynamic] -- list of [Map val (Set a)]
empty item = Syb $ gmapQ (toDyn . emp item) item
where
On 5/18/07, Dan Weston [EMAIL PROTECTED] wrote:
How does the type of fromList get determined? And is Data.Set.toList the
same as Data.Set.toAscList?
As I import just Data.Set there is only one fromList in scope. It has
type (Ord a) = [a] - Set a so there is no ambiguity.
I should have used
On Fri, May 11, 2007 at 12:00:10AM +0200, Lennart Augustsson wrote:
Parsing a very close approximation to what Haskell specifies isn't that
hard. You just need some mild interaction between the parser and lexer.
This algorithm can correctly de-whitespace haskell without any parser
34 matches
Mail list logo