algorithms don't have an extra factor, although f is
clearly larger for them.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
. The naive 'filter (\x - x `mod` p /= 0)' is it as well.
But I agree that the latter deserves more a name like transposed sieve
of Eratosthenes.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo
MonadReader.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
than the
human who can see and cross numbers on a piece of paper at his choice.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
base.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
)
= 1
fib' n = sumtree (fibtree n)
= sumtree $ Branch (fibtree (n-1)) (fibtree (n-2))
= (sumtree $ fibtree (n-1)) + (sumtree $ fibtree (n-2))
= fib' (n-1) + fib' (n-2)
Now, you can optimize the result by memoizing fib'.
Regards,
apfelmus
,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
to
the equivalence
exists a . f a ~= forall r . (forall a . f a - r) - r
Both have of course the problem that we cannot simply write
safeMap (fromList [1,2,3]) :: exists t . List a t
Regards,
apfelmus
Exercise: Why is
fromList :: exists t . [a] - List a t
wrong as well
Felipe Lessa wrote:
apfelmus wrote:
Oh, what kind of generalization do you have in mind?
Leaking Prompt(..) in the export list to the GUI code seems wrong to
me, I like 'runPromptM' because it hides the Prompt(..) data type from
the user [module]. But after some rest I think I found a nice
beta reduction step like
(\x.c(d(e(f(x) g
= c(d(e(f(g
may take 5 steps in some reduction strategies since you have to walk
down the expression tree to find the variable and replace it with its
value. In the end, seconds are a better measure for time :)
Regards,
apfelmus
/projects/rmb/
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Felipe Lessa wrote:
apfelmus wrote:
The type of contPromptM is even more general than that:
casePromptOf' :: (r - f b)
- (forall a,b. p a - (a - f b) - f b)
- Prompt p r - f b
casePromptOf' done cont (PromptDone r) = done r
casePromptOf' done cont
This way, every match_RE r will evaluated to the function
corresponding to r and the result will be shared. In your code,
match_RE r s will be run-time compile the regex matcher for each
string s again and again.
Regards,
apfelmus
___
Haskell-Cafe
a reason the STM monad hatched in Haskell: how does the above
STM in F# handle side-effects like launchMissile ?
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
. In contrast, Duncan's code evaluates
to Data.Set , that's what you want to be strict in.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Monoid m = Category (Mon m) where
id= Mon mempty
(Mon f) . (Mon g) = Mon (f `mappend` g)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
(OrdBy p a))
instance Heap (HeapP p) where ...
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Stephan Friedrichs wrote:
apfelmus wrote:
[...]
Feedback: I think the HeapPolicy thing is too non-standard. The
canonical way would be to use a MinHeap and let the Ord instance
handle everything. A MaxHeap can then be obtained via a different
Ord instance
newtype Ord a = Reverse
)
data Lowered a = Lower a | Top deriving (Eq, Ord)
instead of
type Raised a = OrdBy Down (Maybe a)
type Lowered a = OrdBy Up (Maybe a)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman
p a = Ord (OrdBy p a) where ...
is shorter but not H98 either. The name could be a mot juste, too.
class Rearranged p a where ...
class Ord' p a where ...
class OrdBy p a where ... -- clashes with the name of the type
Regards,
apfelmus
is the interpretation of = in
terms of sequencing actions with side effects. The law is probably best
demonstration with its special case
x (y z) = (x y) z
In other words, it signifies that it's only the sequence of x,y,z and
not the nesting that matters.
Regards,
apfelmus
m does not fulfill the
monad laws, it just shows that naïvely using m [a] to implement the
list monad transformer is incorrect for general m . In other words,
there is a big bug in Control.Monad.List and that's all there is to it.
Regards,
apfelmus
Janis Voigtlaender wrote:
apfelmus wrote:
The subject line is a hyperlink that points to the context thread of
the message (which is displayed with frames).
only in the case of haskell.cafe, but not for haskell.general. (see
my response to Calvin Smith on the cafe list)
Actually
Colin Paul Adams wrote:
Left? Right?
Hardly descriptive terms. Sounds like a sinister language to me.
The mnemonics is that Right x is right in the sense of correct. So,
the error case has to be Left err .
Regards,
apfelmus
___
Haskell-Cafe
cover the System.IO stuff, but you've got the
#haskell irc channel and the mailing list for that. So, the textbook
remark is in anticipation of the questions that you are going to have :)
(if you decide to pursue Haskell further, that is).
Regards,
apfelmus
simple examples since those
are better done by hand. But an unsophisticated tool is useless for the
more complicated cases too, since no one can make sense of the output
anymore!
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe
understand
why this works, and these ad-hoc unique numbers bother me.)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
-recursive. Sometimes, GHCs strictness analyzer is able
to optimize that away.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
in the library doesn't behave as nicely as I'd
have expected. I'd consider the first definition a strictness bug; the
general etiquette is to force arguments from left to right.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
in disguise.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
De Bruijn indices
and even representations based on parametric polymorphism. But I think
that this doesn't touch the issue of alpha-conversion being a natural
Eq instance.)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
here? Something with
sequence :: Applicative f = [f a] - f [a]
being the cartesian product for the list monad? Or simpler
pure (,) :: Applicative f = (f a, f b) - f (a,b)
somehow crossing the elements of f a and f b ?
Regards,
apfelmus
xs ~ merge [x] (merge xs ys)
, but merge3 incorporates the additional insight that we don't need to
pit x against the xs anymore.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo
7 of
the applicative functor paper.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Matthew Pocock wrote:
Who currently maintains the Random monad code?
/me whispers: have a look at
http://code.haskell.org/monadrandom/MonadRandom.cabal
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http
apfelmus wrote:
Krzysztof Skrzętnicki wrote:
class YOrd a where
ycmp :: a - a - (a,a)
Unfortunately, the performance of ysort is rather low. I believe that
it is impossible to create any sorting algorithm that uses ycmp
instead of compare, that is faster than O(n^2).
It is possible
, well, where to start?
Girard and Reynolds?
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
meeting:
http://bayfp.org/talks/slides/philip_wadler_1_jan_08_bayfp.pdf
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
which knows these constants has
-- corresponding permissions
data Restricted p a = Restricted a
readRestricted :: Permission p - Restricted p a - a
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe
, namely O(n (log n)^2) and even better.
Sorting algorithms based on a comparator function like ycmp are called
sorting networks and in fact well-known. See also
http://en.wikipedia.org/wiki/Sorting_network
Regards,
apfelmus
___
Haskell-Cafe
David Roundy wrote:
apfelmus wrote:
David Roundy wrote:
porrifolius wrote:
(7) ideally required permissions would appear (and accumulate) in
type signatures via inference so application code knows which are
required and type checker can reject static/dynamic role constraint
violations
.
The subtle difference in the type synonym family case is that a is
more parametric there. At least, that's my feeling.
In full System F , neither definition would be a problem since the type
a is an explicit parameter.
Regards,
apfelmus
Manuel M T Chakravarty wrote:
apfelmus:
Manuel M T Chakravarty wrote:
Let's alpha-rename the signatures and use explicit foralls for clarity:
foo :: forall a. Id a - Id a
foo' :: forall b. Id b - Id b
GHC will try to match (Id a) against (Id b). As Id is a type synonym
family, it would
Tom Schrijvers wrote:
apfelmus wrote:
However, I have this feeling that
bar :: forall a . Id a - String
with a type family Id *is* parametric in the sense that no matter
what a is, the result always has to be the same. Intuitively, that's
because we may not pattern match on the branch
thing.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
when the left argument changes. In essence, we have the
same problem with parser combinators. Applicative functors to the rescue!
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell
ReadOnlySTM a = StateT TVarEnvironment STM a
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
to express both
the continuation-logging and read-only-fail optimization in terms of
type STM a = Maybe a
or similar?
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Chris Smith wrote:
apfelmus wrote:
For 1), it's enough to have a primitive
scheduleWriteTVar :: TVar a - a - STM ()
that ensures to write the TVar at the very end of the atomically block..
Unfortunately, though, this breaks the very thing that makes STM
attractive: namely
(= g) f
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
that the implementation given in the documentation is wrong.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Don Stewart wrote:
Yeah, if you're on Debian it would make sense to install GHC -- its much
more active, much faster, and supports more things. [than Hugs]
Except for compile and load time, Hugs is really fast there.
Regards,
apfelmus
___
Haskell
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
http://en.wikibooks.org/wiki/Haskell/Denotational_semantics
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
/gmane.comp.lang.haskell.cafe/34398/focus=34435
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Okasaki's book.
[1]: Chris Okasaki. Purely Function Data Structures.
http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
(This is the thesis on which the book is based.)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http
is feels wrong, something like Serialize is
probably a better fit.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
, the whole point of rebasing seems to be to
somehow bring set semantics into the tree semantics.)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
a
paradox :) as Okasaki already points out in his book.
Eager evaluation may waste both time and space compared to alternative
course of reduction.
Regards,
apfelmus
PS: The reduction strategies we compare to don't evaluate under lambdas.
___
Haskell
.
http://web.cecs.pdx.edu/~cklin/papers/unimo-143.pdf
[MonadPrompt]: Ryan Ingram.
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MonadPrompt
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http
, but again, they haven't
been running for very long yet.)
Yeah :( When a piece of softwares wastes time and memory, they should
have written it in Haskell, so that at least the other bugs wouldn't
plague me as well.
Regards,
apfelmus
___
Haskell-Cafe
Ronald Guida wrote:
Thank you, apfelmus. That was a wonderful explanation; the debit
method in [1] finally makes sense.
A diagram says more than a thousand words :)
My explanation is not entirely faithful to Okasaki, let me elaborate.
In his book, Okasaki calls the process of transferring
as advertised.
I've fixed that and also cleaned up the page a bit, moving this sieve to
the section Implicit Heap.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
this.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
= foldl' (zipWith' (+)) zero
. map (foldl' (zipWith' max) zero . map bits)
where
zero = map (const 0) ws
bits v = map (fromEnum . (== v)) ws
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http
is it?).
Regards,
apfelmus
Footnote: We still have to prove the identity
(length sum) . (x:) = (\(n,s) - (n+1,s+x)) . (length sum)
I mean, you can figure this out in your head, but a formal calculation best
proceeds with the two identities
length . (x:) = (1+) . length -- definition
.
Thanks,
No problem, it was not obvious to me and I had fun trying to figure it out :)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
apfelmus wrote:
In other words, we have now calculated the more efficient program
euler201 = map snd . filter ((==50) . fst) . subsums $ squares
where
subsums [] = singleton (0,0)
subsums (x:xs) = map (\(n,s) - (n+1,s+x)) (subsums xs) `union` subsums xs
I forgot something
, this is unsuitable for serious floating point calculations.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
, just hide (*) and
(+) from the prelude and define your own.)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
* tree does not depend on import
statements? I.e. Chasing imports is performed after you've got an abstract
syntax tree.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Hola amigos del Foro ( México ), alguno de ustedes
sabe donde se puede adquirir en nuestro país pedacitos
de fibra de coco, lo que en inglés llaman coconut
husk chips...??
He tenido noticia acerca de su uso exitoso como
ingrediente en la preparación de sustrato, en USA se
puede conseguir
of your program as well.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Tom Hawkins wrote:
apfelmus wrote:
So, in other words, in order to test whether terms constructed with Equal
are
equal, you have to compare two terms of different type for equality. Well,
nothing easier than that:
(===) :: Expr a - Expr b - Bool
Const === Const
Andre Nathan wrote:
I'm trying to write a simple graph library for a project of mine
There's also Martin Erwig's functional graph library in Data.Graph.Inductive (
fgl on hackage).
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe
).
Are you sure that there is no unintentional bug in your implementation that
slows things down?
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
, in a subsequent post, I'll turn the above ideas into a better solution
and I'll also explain why implementing this data structure seems more difficult
in Haskell than in Java.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http
apfelmus wrote:
data Stack2 r b = Empty | S [r] (Stack2 b r) deriving (Eq, Show)
In the previous post, I considered an implementation of red-blue stacks
with the data type above. Unfortunately, it failed to perform in O(1)
time because list concatenation needs linear time:
xs ++ ys takes
I'm not aware of any such results.
Yes, lazy evaluation makes persistent data structures much easier,
sometimes even possible. It only gives amortized times, though.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http
Empty Empty
The red element got lost in the first case.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
I have
something wrong with me...
A much more important question is: how many break bar in two
operations did you perform? Can you do it with less?
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman
Jason Dagit wrote:
apfelmus wrote:
It seems to me that dependent types are best for ensuring totality.
Bear with me, as I know virtual nothing about dependent types yet.
Ah, my bad. Time to change that ;) Personally, I found
Th. Altenkirch, C. McBride, J. McKinna.
Why dependent types
one has to produce one x that works for all b at
once. Here's an example for natural numbers that illustrates the difference:
∀m.∃n.n m -- we can always find a larger number (sure, use n=m+1)
∃n.∀m.n m -- we can find a number larger than all the others!
Regards,
apfelmus
PS
...
... and a solution to a problem that you souldn't have in the first
place. I mean, if you want to construct XML or SQL statements, you ought
to use an abstract data type that ensures proper nesting etc. and not a
simple string.
Regards,
apfelmus
___
Haskell-Cafe
Andrew Coppin wrote:
apfelmus wrote:
... and a solution to a problem that you souldn't have in the first
place. I mean, if you want to construct XML or SQL statements, you ought
to use an abstract data type that ensures proper nesting etc. and not a
simple string.
Right. And if you
Devin Mullins wrote:
apfelmus wrote:
Yes. Just an injection problem is an understatement. And its the
implementation of the abstract data type that determines how fast things
are. Who said that it may not simply be a newtyped String ?
I think the attraction to the SafeString example
Ryan Ingram wrote:
Normally I agree with you, apfelmus, but here at least I have to differ!
/me considers map crushToPurée . filter disagrees ;)
On Mon, Oct 13, 2008 at 11:50 AM, apfelmus [EMAIL PROTECTED] wrote:
*HTML toString $ tag b [] [tag i [] [text ], text test]
bilt;gt;/itest/b
, but the attitude you
complain about is the exact opposite of the attitude of any five year
old children that *I* know (well, my son primarily ;-).
Derek probably meant kids that are three quarters through school ... and
thus no longer interesting in anything. :(
Regards,
apfelmus
]]
[[1,3],[1,4],[2,3],[2,4]]
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
inference already is a kind of mini-prolog. Of course, that doesn't
simplify their semantics at all. In a sense, knowing AT is knowing how
much functional in style type inference can be.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe
that as gmp.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
(Transaction c) where ...
getConnection :: Transaction c c
...
Note that Control.Monad.State does the same.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
= () `by` field_three
Appealing to the famous instance Monad ((-) a), you can also say
and, or :: BoolOp a - BoolOp a - BoolOp a
and = liftM2 $ liftM2 ()
or = liftM2 $ liftM2 (||)
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http
the parameter c
altogether? Why do you intend 'Transaction' to be a state monad, I mean
why is the only thing you can do with the state something of type (c -
String - IO ())? Btw, this has been (c - String - Transaction ()) in
your original post.
Regards,
apfelmus
://www.nt.ntnu.no/users/haugwarb/Programming/haskell_automatic_differentiation_III.pdf
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
.
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
.
Recursive modules are the lazy evaluation of modules and One should not
obstruct access to such a vital tool. I want recursive modules for free!
Regards,
apfelmus
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman
201 - 300 of 837 matches
Mail list logo