A better test might be if they really understood Applicative and
Traversable, or if they knew how to use hsc2hs; Talk about unboxing and when
to apply strictness annotations, finger trees, stream fusion, purely
functional data structures or ways to implement memoization in a purely
functional
Hi Corentin,
Interesting. Have you thought about following the example of XMonad instead?
The analogy could goes as follows:
XMonad's configuration file (~/.xmonad/xmonad.hs) = Your rules.
XMonad's state = Your state.
Editing the config file = Changing the rules.
Of course you normally edit
Hi Ozgur,
Perhaps you can have a look at what discussion there was about
non-empty lists. Seems (slightly) related to me.
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Every question is welcome on haskell-cafe . The goal of
haskell-beginners is to encourage answers that are tailored to
beginners, i.e. no scary existential multi-parameter category theory
type class monads there. :)
Do you get warm fuzzy existential multi-parameter category theory type
Hi Peter,
Interesting. Your skip lists do not need re-balancing, but they do
destructive updates. I wonder which factor outweighs the other in
practise.
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
im planing on going to the hackaton, but the prices in Zurich are unusually
high for my tight budget, so i was wondering if there is anyone here that
lives there and would allow me to sleep on their couch or on the floor
during the hackaton.
Is there ?
Just a suggestion: Have you tried one
I think I've reached the point where I need some tutoring, so provided
I've got money for travel and course fees, and time, where do I get it? I'm
not a student so some courses aren't available to me.
How about visiting our Haskell meeting in Leipzig, June 4th?
Which I can only recommend!
A shining example are Dan Piponis blog posts. Not his fault, mind. All I see
is that there is something powerful. I also notice that the big brains
construct monads in many different ways and thus giving them entirely
different capabilities. An example of this is some techniques turn CBV to
Also, constructions like
sortBy (compare `on` foo)
must surely be very common.
Just as a data point: I use constructions like the above very often.
(Perhaps someone more enlightened than me can point out the connection
to arrows?)
Data.Function.on is surprisingly useful in some other
The trick is to use only non-negative variables for the equations.
(That's considered OK in linear programming. Though you may consider
it cheating.)
By the way, linear programming over rational numbers is in P.
___
Haskell-Cafe mailing list
But, isn't it the case that you can transform any linear inequality into a
linear equality and a slack (or excess) variable? That's actually what you
*need to do* to turn the problem into the canonical form, so that simplex
can handle it.
Yes. The simplex is usually implemented in this form.
As far as I can see, you'd use that for systems of linear equalities, but
for systems of linear inequalities with a linear objective function, it's
not suitable. I may be wrong though :)
There's a linear [1] reduction from one problem to the other and vice versa.
[1] The transformation itself
It might be big for SoC but perhaps there's some well-defined subset,
like fix some blocking issue?
Good idea. By the way, do all SoC projects have to be
single-contributor projects, or could someone get together with a
friend and work together on a somewhat larger project?
Perhaps if you search for Abelian Monad or so, you will find
interesting things in the category theory literature. Some of them
may be transplantable to Haskell --- but you probably don't want a
completely commutative structure. Arrows seem to express the
dependencies between operations more
Implementing an alternative RTS for GHC seems like a viable Google
Summer of Code project to me. What do you think?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
I used Haskell for some Research Development work at Deutsche Bahn,
earlier. (But my program was not integrated with their other
systems.)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
I think this has a lot to do with the fact that
web programming is very much a let's go shopping kind of
discipline -- no point in troubling oneself over correctness
when the users haven't weighed in on the worth of your site.
Of course this attitude leads to a long maintenance phase of
Monads are not commutative. A structure that would tell the compiler
that it's commutative, would give it more leeway for optimization (and
parallel execution).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Using something like zippers it is easy to navigate an acyclic graph
in O(1) operations per arc you follow. Inspired by Chris Okasaki's
work on queues I wondered if there is a similar approach to navigating
cyclic graphs.
If the graph you are navigating is static (i.e. does not have to
support
Dear Dušan,
You can also find an algorithm in everyone's favourite book in
combinatorial logic To Mock a Mockingbird
(http://en.wikipedia.org/wiki/To_Mock_a_Mockingbird).
Cheers,
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hi folks,
I have recently started working for Citrix in Cambridge. We are
working on the open source software in Ocaml. Admittedly Ocaml is
only a second best compared to Haskell ;o) and I hope my post does not
count as too off-topic here. But Ocaml is still a decent language.
My experience
Hi,
it may be a bit too late for you, but in general working through
Smullyan's To Mock a Mockingbird
(http://en.wikipedia.org/wiki/To_Mock_a_Mockingbird) may help in
coming to grips with some of the theory (and intuition) behind
functional programming.
The Real World Haskell book is also a good
All Lisps have special forms which are evaluated uniquely and differently
from function application and are therefore reserved words by another name.
For example, Clojure has def, if, do, let, var, quote, fn, loop, recur,
throw, try, monitor-enter, monitor-exit, dot, new and set!.
Yes, but
Hi Sebastian,
You might also want to look at how xmonad handles it's configuration.
Basically the configuration file is the main-file that produces the
executable and takes in the rest of xmonad as a library. This works
out quite well, but you need a compiler to update the configuration.
_So my strong opinion that solution is only DSL not EDSL_
Why do you think they will learn your DSL, if they don't learn any
other language? And if your DSL includes general purpose stuff, like
functions, control structures, data structures, you'll re-invent the
wheel. Probably porly.
Hi Tom,
Did you make any progress on your Dominion quest? I guess you could
start by modeling `Big Money' and add the other cards (and
interaction) from there.
Also I guess there is a common baseline of things that are inherent in
a lot of card games --- mechanics that cards support: Shuffling,
It would be fantastic to have a little practical real-world challenge
(like building a simple music system, or a simple multi-channel sound
mixer), and work this out in an imperative language, an
object-oriented language, a functional language, and maybe other
languages too, like logic
When OO is about constructing a machine and talking about objects,
and FP is about making little algebraic languages, what would C or
Pascal be like? In these languages, you don't think about objects, but
you don't think about an algebra either? It's been a very long time
since I worked with
I feel that Data.Set and Data.Map should be working together more
closely. For example you can already get the keyset of a Map, but the
`other way' is not built-in. I mean a function with a signature like
Ord k = Data.Set.Set k - (k-v) - Data.Map.Map k v
You can implement it in O(n):
assoc
Hi Felipe,
Interesting idea. But I guess you should clarify what kind of card
games you want to support. E.g, a DSL for trick taking games like
Bridge, Skat or Doppelkopf might be different from one that's good for
Canasta or Rummy. Or do you aim at Solitaire? I'd suggest starting
with a very
Round-to-even means x.5 gets rounded to x if x is even and x+1 if x is
odd. This is sometimes known as banker's rounding.
OK. That's slightly unusual indeed.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
I need to take some elements from the front of a list. However the
criteria are somewhat complex.
walk f [] = []
walk f (x:xs) = case f x
of Just g - x : walk g xs
Nothing - []
For each item the `predicate' f either returns Nothing, when it thinks
we
Thanks to Jason and Felipe. I'll try that approach.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
What is the use case(s) for this function?
I often want to take one more element than takeWhile does, or only
start checking the predicate after taking the first element for sure.
Or both.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Couldn't the same be said for round-to-even, instead of rounding down
like every other language? I doubt any beginners have ever expected
it, but it's probably better.
What do you mean with round-to-even? For rounding down there's floor.
___
However you can use the wider idea of hashing: A nesting of two finite
maps. One fast, but approximative map. And one slow, but exact map.
The quintessential example is an array indexed with some hash function
for the first map. And linked lists of (key,value) pairs as the
latter.
In Haskell
BTW, after a -O2 compilation, fib' is apparently as fast a fib.
The compiler is your friend. :o)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
If one of you knows something about working at Jane Street, I'd be
happy to have exchange some mails. I am considering applying there.
Thanks!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Thomas, if you did no know, where to look for `lazy-memory-hole', say
in your first example, how would you go about solving that puzzle
systematically with a Profiler (or other tools)?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
I tried using your original code and stuffing it into a profiler. But
all I get is a triangle of linearly increasing resource usage, and
then it breaks for lack of stack. I guess I am just to ignorant about
retainer profiling and such stuff.
___
If you don't find anything more specific, I suggest taking a look at
Data.Binary and reading a simple format like BMP or so. (You can
convert your file to BMP with an external program before.)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
By the way, does Hat - the Haskell Tracer?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
By the way, does Hat - the Haskell Tracer?
Please append: still work.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
doesn't make much sense to me yet, although I suspect I can read the mu as a
lambda on types?
Not really. The mu has more to do with recursion.
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Dear Gergely,
Okasaki's Purely Functional Data Structures is a treasure trove of
interesting things to demonstrate Haskell on. Especially the data
structures based on numerical representations (skew binary numbers and
so on) appealed to my mathematical side.
Matthias.
It maybe be that Haskell is harder to learn as your *second* language
because you have to unlearn things. Especially if your first language
was something like C or Python.
Python is not too bad. You can nearly use it a as a strict functional
programming language. While this is not the
code snippet: no hello world please. That's not a way to judge a
language! But: a random haskell one line snippet with explanation would
be cool.
Perhaps a solution to a problem like the ones you can find on Project
Euler (http://projecteuler.net/index.php?section=problems). Of course
you
I like the quicksort example at
http://www.haskell.org/haskellwiki/Introduction very much; it shows how much
time you can save when you use Haskell.
Nice idea. Perhaps use a merge sort, because that is actually useful,
because it does not degenerate for large lists.
Matthias.
Nice idea. Perhaps use a merge sort, because that is actually useful,
because it does not degenerate for large lists.
Great idea if we want to keep Haskell community compact :)))
Or stay with quicksort --- which is treesort. :o)
___
Haskell-Cafe
Interesting. Can you make the definition of quicksort non-recursive,
too? Perhaps with help of a bootstrapping combinator like the one
implicit in the approach I have given earlier?
treeSort = bootstrap partitionOnMedian
bootstrap f = Fix . helper . f
where helper = fmap (Fix . helper .
Thanks. I heard about the hylo-, ana- and catamorphisms before, but
never explicitly used them. Time to get started.
And yet another question: One can get the median in deterministic
linear time. For quicksort choosing the median as pivot keeps the O(n
log n) average running time and brings
One problem I see is the binary-only distribution of packages. This makes
cabal-install incompatible with most distributions except, maybe, gentoo.
The automation process would have to run through hackageDB tracking
dependencies and compiling each needed library. Pretty hard stuff...
Yes.
Dear Hector,
Yes, I thought of a similar scheme. Say we want to implemented
randomized quicksort. Passing a list of random numbers would destroy
laziness and linearise the algorithm --- because the right recursion
branch would need to know at least how many random numbers where
consumed by the
So, a tree like Matthias implements it is the way to go. Basically, it
reifies the recursive calls of quicksort as a lazy data struture which
can be evaluated piecemeal.
Yes. I wonder if it is possible to use a standard (randomized
quicksort) and employ some type class magic (like
What I wondered was, if one could hid the random plumbing in some data
structure, like the state monad, but less linear.
This problem cries for a State monad solution - but you don't need to
do it yourself, there's already a Random monad defined for you.
Yes, but I only need the random
Karmic (9.10) will have GHC 6.10.3, possibly 6.10.4.
It currently spots 6.10.3, in the alpha release I run here.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Since I have two readers now, I guess I'll have to start blogging. :o)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Can someone give some simple common scenarios where the state monad is
useful, besides labeling trees?
Emulating the VM given in this years ICFP programming contest was also
a good application of the state monad. Of course you interprate much
simpler language imperative languages, too.
Interesting problem. I have been toying with the same problem for some time.
To solve the problem in theory, I'd concentrate on getting the number
of comparisons into the required O(n) resp. O(n log n) ranges.
Afterwards we can think about building the infrastructure to keep the
number of all
If someone can translate my algorithm into a non-side-effecting one,
I'd appreciate it, but I think that like disjoint set/union, this is
probably inherently side-effecting. Yes, yes, we could use functional
arrays, but short of that I don't see a way to avoid side effects to
take care of my
It seems to me, that you just need a selection algorithm which works in
O(n * k) time for k arbitrary elements. If you combine O(n*k) selection
algorithm with any O(n * lg n) sort, you furfil your time constrain.
I guess, we also want the list to be sorted in O(1) after having
selected every
The sorted array of bags of unsorted input is a nice idea. However,
you have to use the data structure in a single-threaded [1] fashion to
obtain the claimed bounds.
Here's a pure solution that uses amortization and laziness.
import qualified Data.Sequence as S
import Data.Sequence (())
A Las Vegas algorithm, like randomized quicksort, uses a source of
randomness to make certain decisions. However its output is
unaffected by the randomness. So a function
f :: RandomGen g = g - a - b
implementing a Las-Vegas-Algorithm 'looks' like a pure function,
ignoring its first argument
process [] = return ()
process (file:files) = do x - doit file
if x0 then process files
else return ()
Or use a fold:
process' = foldl op True files
op True file = doit file
op False _ = False
process' = foldl op True files
op True file = doit file
op False _ = False
Please pardon me. 'doit' should surely be able to do some IO:
import Data.Foldable
import System.IO
process' = foldlM op True files
op True file = doit file
op False _ = return False
were DoIt has the type
Hi Günther,
here is a solution with the Maybe Monad:
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6515#a6515
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
P.S. See http://en.wikibooks.org/wiki/Haskell/Monad_transformers for
some documentation.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
P.P.S. Strange it does not seem to work with the paste. So here comes
the solution by mail:
module Consolidator.BusinessLogic.ConflictsResolved
(consolidateDuplicates) where
import System.FilePath
import System.Directory
import Control.Monad (filterM)
import Control.Exception (throwIO)
import
The byte code for the virtual machine of this years ICFP specified a
language with single assignment per simulation step. Interestingly
most memory locations get overwritten each simulation step before they
are read. That means, those locations don't have to be remember
between steps. Also
As a side note, (allowing seq and unsafePerformIO if necessary) is it
possible to implement a map that preserves cycles (instead of
transparently replacing them with infinite copies? Not horribly
useful, but would be quite cute.
Baltasar Trancon y Widemann gave a talk on a generalized
you will find it there but it's written in German.
Yes. But at least there's an English abstract.
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
By the way, how would one write the following with Monad Transformers?
newtype IOMayfail a = IOMayfail (IO (Maybe a))
instance Monad IOMayfail where
return = IOMayfail . return . return
(=) a f = IOMayfail (bind (run a) (run . f))
fail s = trace s (IOMayfail $ return Nothing)
Thanks. Can I add something like fail?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
I have a program that optimizes train schedules. It employs an
external solver for Integer Linear Programs. The solve function has
the following type:
solve :: Constraints - IO (Maybe Solution)
And this works. However, my external solver also behaves like a pure
function from input to
Adding 'unsafePerformIO' will work, but a better idea might be to
understand why your solver has IO in its type signature. Is this because
of FFI calls? You can remove IO in FFI calls if they are free from side
effects as well.
My solver has IO in the type signature, because I said so. :o)
Still, a fast and general way to output primitive data types would be
quite welcome.
Naive question: Can't we just ask C to do it for us? (With a foreign
function call.)
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Mercury also has type classes and other Haskellisms, so if you're
interested in doing Prolog the Haskell way, you should definitely
have a look at it.
I have to admit that I am not very familiar with Mercury. But if you are
looking for doing Prolog the Haskell way advertiseyou can also have
There are a number of ways to marry purely functional programming
languages with IO. To name just two possibilities: Clean uses linear
types, threading exactly one World through functions, Haskell uses
Monads.
The model in Prolog, however, looks more like the model used in most
strict functional
Mercury also has type classes and other Haskellisms, so if you're
interested in doing Prolog the Haskell way, you should definitely
have a look at it.
Thanks. I'll have a look.
(I also just found Mercury on my own: After I posed my original
question, I tried another web search, and found
Hello,
Please pardon my naive question: Is there a way to sign on for ICFP
09? The homepage (http://www.cs.nott.ac.uk/~gmh/icfp09.html) only
seems to mention how to submit papers. Is there a way to attend as a
mere participant?
Thanks,
Matthias.
___
Registration will be open soon.
Thanks.
(I could have written an Experience Report about how I am using
Haskell at Deutsche Bahn, but that deadlines had already passed.)
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hi,
By the way: Would it be considered good style to include QuickTest
properties into the pidigit submission?
Matthias.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Hello,
Or --- if you just want pretty trees and you are not confined to the
command line: You can generate GraphViz code and use that program to
draw your tree in PostScript. (There is also a GraphViz-package, but
generating the code yourself is easy.)
Matthias.
83 matches
Mail list logo