I'd like to bring the thread that began with a question about ``why
the "classic sieve" example did so badly when compared to "a C
implementation of the same thing"'' back to its starting point. In
the discussion that ensued, various people have spoken about various
algorithms to find prim
Hi Tom,
Tom Hawkins wrote:
Folding was my first approach:
leaves :: Tree -> Set Int
leaves tree = accumLeaves Set.empty tree
accumLeaves :: Set Int -> Tree -> Set Int
accumLeaves set (Leaf n) = insert n set
accumLeaves set (Branch l r) = foldl accumLeaves set [l,r]
However, with this approach
Dear Colleagues,
You may now resgister for TFP 2007! TFP 2007 will be held April 2-4, 2007
in New
York City, USA. Our invited speaker is John McCarthy, Stanford University.
Further
details can be found at our homepage: http://cs.shu.edu/tfp2007/ .
You may register at: http://cs.shu.edu/tfp200
On 2/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
First of all, the design already exhibits the problem:
[snip]
The reason is that [..]
the function delaySY is declared *fully* polymorphic over 'a' -- there
are no constraints on a and no restrictions. However,
> delaySY :: HDPrimType
Alfonso Acosta wrote:
> class Synchronous s f1 f2 | s -> f1, s -> f2 where
> mapSY :: f1 a b -> s a -> s b
> delaySY:: a -> s a -> s a
> zipWithSY :: f2 a b c-> s a -> s b -> s c
>
> The goal of this class is to extend the name of the following
> functions (which BTW ar
I second this plea.
-- Jeff
On Wednesday 21 February 2007 22:34, P. R. Stanley wrote:
> and can I please ask anyone thinking of using special symbols to
> resist the temptation.
> Symbols such as the &160 used liberally in the Haskell wikibook are
> totally invisible to screen readers.
> I would
I don't want to duplicate anyone's work, and I'm not sure that NDA would allow
me to release the code in any case (have to check on it carefully), but is
anyone currently using the CUDA framework from nVidia inside of Haskell for
highly parallel programming?
-- Jeff
and can I please ask anyone thinking of using special symbols to
resist the temptation.
Symbols such as the &160 used liberally in the Haskell wikibook are
totally invisible to screen readers.
I would be happy to proof read any document before it goes to the
wikibook to ensure it's fully accessi
I made a preliminary page, and fleshed out some of the
headers/sub-headers on the wiki page for a good Haskell Cookbook (aka
NOT a PLEAC clone). Please contribute and/or fix the examples and
explanations so we can make a really nice Cookbook for newbies. :)
http://haskell.org/haskellwiki/Coo
Neil,
I think this idea is better than what I had suggested, but as it
stands it doesn't typecheck. Did you mean something like this?
leaves :: Tree -> [Int]
leaves = f []
where
f rest (Leaf n) = n : rest
f rest (Branch l r) = f (f rest r) l
-Chad
---
(fr
On 2/21/07, Chad Scherrer <[EMAIL PROTECTED]> wrote:
Tom,
I think inserting elements would be a lot faster than multiple unions.
I would try:
leafList :: Tree -> [Int]
leafList (Leaf n) = [n]
leafList (Branch left right) = leafList left ++ leafList right
leaves = fromList . leafList
If you're
The haddock at
http://www-users.cs.york.ac.uk/~ndm/projects/safe/Safe.html
doesn't indicate that Safe.List already exists. It seems Safe.List
would indeed be a new module in that heirarchy. That said, it may be a
bit confusing to see both approaches in the same package, but both do
support "safet
Nicolas Frisby wrote:
> Some of the code from the previous wiki link, type-level decimal
> numbers
I would rather advice against type-level decimal numbers, if we are
looking at a lightweight solution. The [complete] code at
http://www.haskell.org/haskellwiki/Non-empty_list
is Haskell98!
On 2/21/07, Alfonso Acosta wrote:
> In my opinion adding Type-level lambdas would be the way to go, but
> they unfortunately are not part of Haskell.
Type-level lambdas are already present in Haskell. Please see the
messages
On computable types. I. Typed lambda and type closures
http://www.has
On 2/21/07, Alfonso Acosta <[EMAIL PROTECTED]> wrote:
In my opinion adding Type-level lambdas would be the way to go, but
they unfortunately are not part of Haskell.
[snip]
Is there any extension to the language covering type-level lambdas or
even a plan to include them in next revision?
SP
Despite the fact that I like head/fromJust etc, a safe list library
would be kind of handy. If someone wants to roll that into the Safe
library, as Safe.List or something, I'd be happy to accept patches
(saving someone else the hassle of setting up a new library etc, for
roughly the same purpose)
On 2/19/07, Yitzchak Gale <[EMAIL PROTECTED]> wrote:
Simon Peyton-Jones wrote:
> Yitz, Please do make time to do this!
> This is the moment, while it is still fresh in your mind.
Of course, you are correct. Thanks for the push.
I am a bit busy with work, but the information is not
lost. I'll hav
Hi Ian,
On 2/22/07, Ian Lynagh <[EMAIL PROTECTED]> wrote:
I've just added th-lift to hackage (http://hackage.haskell.org/). You
can use it to Derive lift for existing types.
If only I knew about it before coding it by hand. It anyway it wasn't
that bad cause I only support a subset of the AST
On Feb 21, 2007, at 20:47 , [EMAIL PROTECTED] wrote:
Albert Y. C. Lai wrote:
[EMAIL PROTECTED] wrote:
Albert Y. C. Lai wrote:
If and only if the database is a purely functional immutable data
structure, this can be done. [...]
Many interesting databases are not purely functional immutable;
On Wed, Feb 21, 2007 at 06:37:33PM +0100, Alfonso Acosta wrote:
>
> In my opinion it would be a good idea to include an Lift instantiation
> of Language.Haskell.TH.(Exp,Dec,Type) in the TH library.
I've just added th-lift to hackage (http://hackage.haskell.org/). You
can use it to Derive lift for
Hi Tom
data Tree = Branch Tree Tree | Leaf Int deriving (Eq, Ord)
leaves :: Tree -> Set Int
leaves (Leaf n) = singleton n
leaves (Branch left right) = union (leaves left) (leaves right)
The standard method for a traversal over leaves with accumulation is:
leaves :: Tree -> Set Int
leaves x
Hi
IMHO I think that isJust/fromJust could simply be removed. Using
'maybe' is a much better practice, it is safe and much even more
expressive.
Yes, its more expressive if you let someone write (error "Umm, what
should I do here?") as one of the options. And now you've gone from
something wit
Hi
pidigits is not (currently) one of the nofib programs (phew :-).
Shame...
I suppose the
reason for the results is because the test spends most of its time in GMP?
Taking a brief look that does indeed appear to be true. I don't think
there could be any other reason for Yhc getting so clo
Tom,
I think inserting elements would be a lot faster than multiple unions.
I would try:
leafList :: Tree -> [Int]
leafList (Leaf n) = [n]
leafList (Branch left right) = leafList left ++ leafList right
leaves = fromList . leafList
If you're writing many functions on Trees (or maybe even if you
tomahawkins:
> Hello,
>
> Any recommendations for speeding up extracting the set of leaves from a
> tree?
>
> data Tree = Branch Tree Tree | Leaf Int deriving (Eq, Ord)
>
> My slow, naive function:
>
> leaves :: Tree -> Set Int
> leaves (Leaf n) = singleton n
> leaves (Branch left right) = uni
On 2007-02-21, Joe Thornber <[EMAIL PROTECTED]> wrote:
> On 2007-02-10, Peter Berry <[EMAIL PROTECTED]> wrote:
> Prelude> putStrLn $ concatMap (flip (++)"\n") $ map show $ [(x,y,(&&) x
y)
> |x <- [True,False],y <- [True,False]]
This can be simplified slightly to:
Prelude > putStrLn . unlines
I would be interested in seeing a multithreaded solution, with each
child thread crossing off the multiples of its own prime. The parent
thread would be blocked from spawning a new thread for multiples of the
next prime p until all existing child threads are past p.
It is not clear to me what
One possible way to generate the values would be using a generic function
for permutation with repetition, such as:
permuteRep :: [a] -> [b] -> [[(a,b)]]
permuteRep [] _ = []
permuteRep (a:[]) bs = [ [ (a,b) ] | b <- bs ]
permuteRep (a:as) bs = concat [ [ (a,b):p | p <- permuteRep as bs ] | b <-
On 2/21/07, Jules Bean <[EMAIL PROTECTED]> wrote:
Gene A wrote:
> Prelude> let revApply a f = f a
> Prelude> let rMap a fs = map (revApply a) fs
> Prelude> rMap 2 [(*4),(^2),(+12),(**0.5)]
> [8.0,4.0,14.0,1.4142135623730951]
>
Note that revApply here is precisely flip ($).
And ($a) is the sam
Albert Y. C. Lai wrote:
> [EMAIL PROTECTED] wrote:
>> Albert Y. C. Lai wrote:
>>
>>> If and only if the database is a purely functional immutable data
>>> structure, this can be done. [...]
>>> Many interesting databases are not purely functional immutable; most
>>> reside in the external world a
Alternatively, the definition of your tree could include a list of linked
lists, one for each level of the tree. Then you could just select the last
list and it's the same as saving only the leaves from a complete inorder walk
of the tree.
data AltTree a = AltTree { tree_structure :: Tree a, n
Hello,
Any recommendations for speeding up extracting the set of leaves from a tree?
data Tree = Branch Tree Tree | Leaf Int deriving (Eq, Ord)
My slow, naive function:
leaves :: Tree -> Set Int
leaves (Leaf n) = singleton n
leaves (Branch left right) = union (leaves left) (leaves right)
In m
[EMAIL PROTECTED] wrote:
Albert Y. C. Lai wrote:
If and only if the database is a purely functional immutable data
structure, this can be done. [...]
Many interesting databases are not purely functional immutable; most
reside in the external world and can spontaneously change behind your
prog
Henning Thielemann wrote:
> At
> http://www.haskell.org/hawiki/HaskellDbTutorial
> it is described, how database queries can be modelled with a monad.
> However, I wonder if this is also possible without monads. Say, writing
>
> "DB.map col1 $ DB.filter (\row -> col2 row == 10+2) myTable"
>
> fo
Hi Nick,
On 2/16/07, Nicolas Frisby <[EMAIL PROTECTED]> wrote:
I don't particularly like using fromJust or head, and there's been
IMHO I think that isJust/fromJust could simply be removed. Using
'maybe' is a much better practice, it is safe and much even more
expressive.
head on the other han
Henning Thielemann wrote:
At
http://www.haskell.org/hawiki/HaskellDbTutorial
it is described, how database queries can be modelled with a monad.
However, I wonder if this is also possible without monads. Say, writing
"DB.map col1 $ DB.filter (\row -> col2 row == 10+2) myTable"
for
"SELECT c
The example wasn't really clear, I anyway solved the issue. Here is a summary.
The problem:
There are some cases (at least when developing a DSEL with Templpate
Haskell like I am) in which it might be really useful to keep the AST
gathered by the TH quasi quotes for later processing during exec
Now I'm facing another problem, sorry if it takes too long to reach
the Type level lambdas issue ...
The full definition of my class is
class Synchronous s f1 f2 | s -> f1, s -> f2 where
mapSY :: f1 a b -> s a -> s b
delaySY :: a -> s a -> s a
zipWithSY :: f2 a b c-> s a -> s b
Gene A wrote:
Well this is not very sexy, no monads or anything, but I kinda believe
in Keep It Simple:
Prelude> let revApply a f = f a
Prelude> let rMap a fs = map (revApply a) fs
Prelude> rMap 2 [(*4),(^2),(+12),(**0.5)]
[8.0,4.0,14.0,1.4142135623730951]
Note that revApply here is preci
On 2/21/07, Henning Thielemann <[EMAIL PROTECTED]> wrote:
On Tue, 20 Feb 2007 [EMAIL PROTECTED] wrote:
> Paul Moore wrote:
> > I'm after a function, sort of equivalent to map, but rather than
> > mapping a function over a list of arguments, I want to map a list of
> > functions over the same a
Thanks, the functional dependency solved the problem
On 2/21/07, Yitzchak Gale <[EMAIL PROTECTED]> wrote:
Hi Alfonso,
You wrote:
> Could not deduce (Synchronous s f11)
> from the context (Synchronous s f1)
> \begin{code}
> class Synchronous s f1 where
> mapSY :: f1 a b ->
At
http://www.haskell.org/hawiki/HaskellDbTutorial
it is described, how database queries can be modelled with a monad.
However, I wonder if this is also possible without monads. Say, writing
"DB.map col1 $ DB.filter (\row -> col2 row == 10+2) myTable"
for
"SELECT col1 FROM MyTable where col2
Hi Alfonso,
You wrote:
Could not deduce (Synchronous s f11)
from the context (Synchronous s f1)
\begin{code}
class Synchronous s f1 where
mapSY :: f1 a b -> s a -> s b
delaySY :: a-> s a -> s a
sourceSY :: f1 a a -> a-> s a
sourceSY f s0 = o
On Tue, 20 Feb 2007 [EMAIL PROTECTED] wrote:
> Paul Moore wrote:
> > I'm after a function, sort of equivalent to map, but rather than
> > mapping a function over a list of arguments, I want to map a list of
> > functions over the same argument. The signature would be [a -> b] -> a
> > -> [b], but
Hi,
I'm a newbie to multiparameter classes and I'm getting this error from
GHC when compiling the following class definition:
Could not deduce (Synchronous s f11)
from the context (Synchronous s f1)
arising from use of `delaySY'
Possible fix:
add (Synchronous s f11) to the c
simonmarhaskell:
> Neil Mitchell wrote:
> >Hi Simon
> >
> >>Benchmarks please! Let's see some comparisons on the nofib suite. If
> >>there's a
> >>factor of 2 or less between GHC -O2 and YHC for any of the nofib
> >>programs, I'll
> >>eat my keyboard for lunch :-)
> >
> >http://www.cse.unsw.ed
Neil Mitchell wrote:
Hi Simon
Benchmarks please! Let's see some comparisons on the nofib suite. If
there's a
factor of 2 or less between GHC -O2 and YHC for any of the nofib
programs, I'll
eat my keyboard for lunch :-)
http://www.cse.unsw.edu.au/~dons/nobench/bench.results
Test: pidigit
On Thu, 15 Feb 2007, Nicolas Frisby wrote:
> I would also appreciate references to your favorite discussion about
> uses of head and other unsafe functions or various Oleg posts showing
> how they're all unnecessary. I'll find these on my own, but I would
> also like to know which ones strike a c
On Tue, 13 Feb 2007, Twan van Laarhoven wrote:
> Stefan Heinzmann wrote:
>
> > Hi all,
> >
> > is there a library for Haskell that implements scaled integers, i.e.
> > integers with a fixed scale factor so that the scale factor does not
> > need to be stored, but is part of the type?
>
> Data.Fix
On Tue, 13 Feb 2007, Stefan Heinzmann wrote:
> Hi all,
>
> is there a library for Haskell that implements scaled integers, i.e.
> integers with a fixed scale factor so that the scale factor does not
> need to be stored, but is part of the type?
I have implemented them in a generic way for Numeri
Hi Simon
Benchmarks please! Let's see some comparisons on the nofib suite. If there's a
factor of 2 or less between GHC -O2 and YHC for any of the nofib programs, I'll
eat my keyboard for lunch :-)
http://www.cse.unsw.edu.au/~dons/nobench/bench.results
Test: pidigits (lazy, arbitrary preci
On 2/10/07, Peter Berry <[EMAIL PROTECTED]> wrote:
Prelude> putStrLn $ concatMap (flip (++)"\n") $ map show $ [(x,y,(&&) x y)
|x <- [True,False],y <- [True,False]]
This can be simplified slightly to:
Prelude > putStrLn . unlines . map show $ [(x, y, x && y) | x <-
[True, False], y <- [True, Fal
52 matches
Mail list logo