I'm looking for cool but mind-bending examples of functional brilliance.
Let us say, hypothetically, you had a bathroom without any reading
material. And having read all the Dilbert and Garfield you could
seriously stomach, decide you should educate yourself while on the
job. :-)
So you decide
On 14/08/07, Brent Yorgey [EMAIL PROTECTED] wrote:
Clearly, we need to actually put together such a book! I'm imagining
something where you have two mostly blank facing pages, with the code by
itself in the middle of the right page; then the next 2-4 pages devoted to a
short discussion of the
On 14/08/07, Dan Weston [EMAIL PROTECTED] wrote:
[snips another metaphor for monadic programming]
No offence to Dan, whose post I enjoyed. The concept of wrapping is as
close a metaphor as we seem to get without disagreements. But this has
brought me to a realisation, after Paul Erdos:
The
On 05/08/07, Frank Buss [EMAIL PROTECTED] wrote:
Is it possible to write functions with an arbitrary number of arguments?
Would be nice if the average function would accept any number of pixel
values.
I think it's possible in some sense, because the Haskell
interpretation of printf() works in
On 03/08/07, Dave Bayer [EMAIL PROTECTED] wrote:
I'm actually calling
Markdown.pl on tiny files (source code of lengths a human would read), and
it is certainly sluggish enough to be a fair test.)
I had to do this recently, so you might be interested in my approach:
On 03/08/07, Bryan O'Sullivan [EMAIL PROTECTED] wrote:
Pardon me while I veer off-topic, but you could also use Pandoc to do
this. No forking required.
http://sophos.berkeley.edu/macfarlane/pandoc/
I'll add that to the list of things that must be done. That list
seems, necessarily, to be
On 02/08/07, Alexis Hazell [EMAIL PROTECTED] wrote:
It's at this point that i feel there's an issue. Haskell Monads are used FOR
many many things. And rather than get to the core of what a Monad is, many
people provide two or three motivating examples - examples which merely serve
to show
On 01/08/07, Andrew Wagner [EMAIL PROTECTED] wrote:
This seems wrong to me. A monad is, first and foremost, a type
constructor class. I'm not sure how you can really compare that to a
loop. But perhaps the easiest way to test your definition would be to
ask this: How is, for example, the Maybe
On 31/07/07, peterv [EMAIL PROTECTED] wrote:
Having only a couple of days of practice programming Haskell (but having
read lots of books and docs), I find myself writing very explicit low level
code using inner aux functions (accumulators and loops). Then I force
myself to revise the
On 27/07/07, anon [EMAIL PROTECTED] wrote:
I see what you did there. But you really might as well end sentences
with prepositions. Or begin them with conjunction. Or indent your code
whichever way seems most natural and elegant because to do otherwise
is just prescriptivism for its own sake.
On 18/07/07, apfelmus [EMAIL PROTECTED] wrote:
I like it for its elegant point-free style :)
Yes, well, I am rather enamoured of them! :-)
Apparently, difference can only detect character replacements but not
character insertion or deletion, but that's probably not your use case.
Yes,
On 18/07/07, J. Garrett Morris [EMAIL PROTECTED] wrote:
You're partway there - concatMap is flip (=), so you have the xs =
(\x - stuff) part.
Ah, yes! I read about this equivalence in one of the other threads
today but it didn't make any connection. Doh!
I think I will have to, sooner or
The following is a slap-dash program for generating a list of pairs of
words which differ by, at most, one letter. It's quite verbose at the
moment, because (a) that was the way I wrote it, a snippet at a time,
and (b) I lack the wit to make it shorter.
Can anyone recommend ways to make this
On 13/07/07, Jim Burton [EMAIL PROTECTED] wrote:
As well as being nice, can't you sometimes tell people to RTFM? Or,
You've asked that before, or That's an FAQ, search the archive?
I suppose you could, but speaking as someone who doesn't know much but
tries to answer questions when he does
On 12/07/07, Crediné Menezes [EMAIL PROTECTED] wrote:
I have written this code in Haskell which gives an unresolved
overloading error.
g x = [2] ++ [3,5..truncate(sqrt x)]
p n= fp n (g n)
fp n [ ]= True
fp n (x:xs) = if (mod n x) == 0 then False else fp n xs
On 11/07/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
You mean nstructed.
Now if you'l excuse me, I'm off to write some de.
Ah, everyone's a median ;-)
Cheers,
Dougal.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hi Haskellers,
It seems that profiling and threading are not supported at the same
time in GHC6.6. At least, it objects to using both the flags at the
same time, and there's a Trac entry for that issue.
So I just wanted to be sure that I really need threading. I'm passing
text through some
On 03/07/07, peterv [EMAIL PROTECTED] wrote:
In Haskell, currying can only be done on the last (rightmost) function
arguments.
So
foo x y
can be curried as
foo x
but not as
foo ? y
where ? would be a wilcard for the x parameter.
The function flip can be used in
On 27/06/07, Balu Raman [EMAIL PROTECTED] wrote:
equilateralTri :: Window - Int - Int - Int - IO()
equilateralTri w x y side
= drawInWindow w (withColor Red
(polygon
[(x,y),(a,b),(x,y)]))
On 27/06/07, Paul Hudak [EMAIL PROTECTED] wrote:
I think that an easier solution is to just change the type of
equilateralTri to:
equilateralTri :: Window - Float - Float - Float - IO()
But I am on the road and wasn't able to actually run the code.
I don't have my copy of SOE to hand, so I
On 22/06/07, Claus Reinke [EMAIL PROTECTED] wrote:
perhaps this should be generalised to ghc flag profiles, to cover
things like '-fno-monomorphism-restriction -fno-mono-pat-binds'
or '-fglasgow-exts -fallow-undecidable-instances; and the like?
You just *know* someone's gonna abuse that to
On 22/06/07, Michael T. Richter [EMAIL PROTECTED] wrote:
So, I'm now going over the code in the 'Report with a fine-toothed comb
because a) I'm actually able to read it now pretty fluently and b) I want to
know what's there in detail for a project I'm starting. I stumbled across this
code:
On 21/06/07, Andrea Rossato [EMAIL PROTECTED] wrote:
runComLoop :: String - IO ()
runComLoop command =
do (r,w) - createPipe
wh - fdToHandle w
hSetBuffering wh LineBuffering
p - runProcess command [] Nothing Nothing Nothing (Just wh) (Just wh)
rh - fdToHandle r
On 19/06/07, Brent Yorgey [EMAIL PROTECTED] wrote:
PS Also, did anyone get my e-mail to this list of June 8 about Template
Haskell and QuickCheck? If you did and it's just that no one knows the
answer to my questions, no problem. But I was subscribed in a strange way
(through the fa.haskell
On 06/06/07, Steffen Mazanek [EMAIL PROTECTED] wrote:
Hello,
is there a function f::[a-b]-a-[b] in the libraries? Couldn't find one
using
hoogle although this seems to be quite a common thing...
Possibly it's just too small to bother putting in a separate function.
let fs = [ (*2), (+2),
On 05/06/07, Claus Reinke [EMAIL PROTECTED] wrote:
(tested on ghc/compiler/stranal/StrictAnal.lhs):
Since when did GHC become NSFW?! :-O
/ducking and running...
D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On 31 May 2007 21:52:33 +0100, Jon Fairbairn [EMAIL PROTECTED] wrote:
Yes, but you didn't say that it's not only silly but
demonstrates the opposite of expressiveness as it's all
about breaking an abstraction and must be non-portable code
(because it's definition is that it won't give the same
On 23/05/07, Donald Bruce Stewart [EMAIL PROTECTED] wrote:
Bryan O'Sullivan, Don Stewart and John Goerzen are pleased, and frankly,
very excited to announce that were developing a new book for O'Reilly, on
practical Haskell programming. The working title is Real-World Haskell.
That is
On 17/05/07, Eric [EMAIL PROTECTED] wrote:
H|i,
Does anyone know of a simple and straightforward way to use global
variables in Haskell?
You can pass around an environment with the State or Reader monads
(read/write and read-only respectively). If you want to do IO with the
data you'll
On 17/05/07, Jules Bean [EMAIL PROTECTED] wrote:
I'd be willing to take a sportsman's bet that the original poster
does not actually need to use this hack; I doubt his application falls
into the categories you have outlined. I would discourage people from
using this hack unless it is, in fact,
On 17/05/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote:
just to cover the bases: cd hpodder?
Yes, did that! ;-) I realise it wasn't very clear from the snippet I
provided. This, however, is a direct copy-n-paste:
[EMAIL PROTECTED] hpodder $ ls
Commands COPYINGDB.hs
On 07/05/07, David House [EMAIL PROTECTED] wrote:
represented by a null pointer. So such luck with unboxed types. So
working with unboxed types is quicker and consumes less memory, but
don't use them in any kind of high level because the lack of a _|_
will bite you sooner or later.
I hesitate
On 05/05/07, Donald Bruce Stewart [EMAIL PROTECTED] wrote:
I've created a wiki page collecting the 'functional pearl' papers that
have appeared in JFP and ICFP and other places over the last 20 odd
years.
http://haskell.org/haskellwiki/Research_papers/Functional_pearls
Lots of lovely
On 03/05/07, Thomas Schilling [EMAIL PROTECTED] wrote:
I once used this perl script to determine the files I was actually
used (to have proper LOC stats). It uses ghc -M which usually
outputs the dependencies as makefile targets, and then grep over this
to get all the .hs files. If you have
On 03/05/07, Thomas Schilling [EMAIL PROTECTED] wrote:
Oh, right. Well, then please file it as a bug report on Cabal. I'll
be working on Cabal configs as my Summer of Code project; this is
clearly related. With a bit of luck it'll be done before end of August.
Okay. It seemed like a
On 27/04/07, Fernando Cassia [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] ghc-6.6.1]# ghc
/usr/local/lib/ghc-6.6.1/ghc-6.6.1: error while loading shared libraries:
libreadline.so.4: cannot open shared object file: No such file or directory
#
So, I conclude that Haskell is not ready for prime
If I'm doing development between ghci and vim, all the different
dependencies I need get linked in when required without me asking.
Similarly if I call ghc --make from the command line. But I have to
write them in manually to my *.cabal file otherwise the compilation
process will fail.
Until now
On 27/04/07, Jim Burton [EMAIL PROTECTED] wrote:
I have a couple of questions about my first use of Parsec, which is trying
to read morse code symbols from a string. I have a map of symbols:
import qualified Data.Map as M
morsemap = M.fromList [('A', .-)
...
On 25/04/07, Tony Morris [EMAIL PROTECTED] wrote:
In a debate I proposed Excel is a functional language. It was refuted
and I'd like to know what some of you clever Haskellers might think :)
By coincidence I wrote about Excel (and related spreadsheets) as
functional languages just recently
On 23/04/07, David Waern [EMAIL PROTECTED] wrote:
What IDE support is available for Haskell (Visuall Haskell, EclipseFP),
anything else?
I'm working in Haste2[1]. But it is unreleased :P
[1] http://www.dtek.chalmers.se/~davve/haste2-new.png
That's really clean-looking and undistracting.
On 22/04/07, Ryan Dickie [EMAIL PROTECTED] wrote:
Many of the haskell packages including darcs, ghc, and well over 100 other
packages (mostly libraries) are in the package manager ready to be
installed.
The problem with Ubuntu (at least until the Feisty release a few days
ago?) was that GHC
On 18/04/07, R Hayes [EMAIL PROTECTED] wrote:
One of the truly powerful things about Haskell is the short distance between
theory and practicality. The problem is how to demonstrate this
convincingly. The ability to prove a program's correctness is regularly
trotted out for show in this arena
On 16/04/07, Thomas Hartman [EMAIL PROTECTED] wrote:
Maybe that could be simplified and something could be based on that.
A one-liner using PCRE regex might also be of use.
Unless it can be performed with astounding dexterity, I don't think
try to beat, for example, Perl at its own game
On 05/04/07, Thomas Hartman [EMAIL PROTECTED] wrote:
In the spirit of...
I hate package chasing, cabal doesn't do this automatically (yet),
and hard disk space is cheap...
Agreed. As much as I like the rest of Ubuntu I'm beginning to dislike
binary packages after only a week away from
On 30/03/07, Bayley, Alistair [EMAIL PROTECTED] wrote:
Mhh, still I don't see any them in my inbox mails , probably something
buggy in gmail configuration, sorry :/.
Are you expecting to see your sent message eventually arrive in your
inbox? gmail doesn't do that by default (and I don't see
On 29/03/07, Greg Buchholz [EMAIL PROTECTED] wrote:
Something out of Unicode?
≬⊳⌁⋆☕⚡‣‸‡⁏•△▴◆◇◊◬◢◮♘♣♲♪◖▻▿轢
There should be a good candidate for a rational arrow notation in
there! I always found the a - b - c syntax a bit disturbing. :-)
D.
unix sort util act
like this? Enh, who cares, now we have haskell. :)
Alas, foiled again! ;-)
sort flag:
-n, --numeric-sort
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell
it
only applied to Unix systems but maybe the library assumes something it
shouldn't at some point.
[1]: http://en.wikipedia.org/wiki/Year_2038_problem
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman
a more decentralized design, where each module
contributes one main type and according functions.
That sounds like a kind of stateless object-oriented approach.
Interesting. I probably do something like that but have never really
formalised my thoughts on the matter. Nice one!
--
Dougal Stanton
but it sometimes makes a difference
when things actually happen.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
contributors to The Monad Reader,
who help to bridge that gap for the rest of us.
Cheers,
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
in the first place. So --- where's the
cutoff point in your code?
Cheers,
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
.
Yeah, here we go: PanDoc [1], which converts between Markdown,
reStructured Text, HTML, LaTeX and also RTF, DocBook and HTML
slideshows.
I've never used it but it sounds pretty nifty.
[1]: http://sophos.berkeley.edu/macfarlane/pandoc/
--
Dougal Stanton
On 08/03/07, Dan Weston [EMAIL PROTECTED] wrote:
Do not let the multiple responses of how you apparently wasted your time
reinventing (or do they mean stealing?) something Church did long ago
dampen your enthusiasm to learn exciting things and then share them.
I agree with your sentiment that
don't pop anything until
you reach the end of the code. So the mental model required to read code
containing $'s is simpler than that required for parentheses.
Which is the longer way of saying you don't need to count to make sure
you closed all the brackets you opened! ;-)
D.
--
Dougal Stanton
, here we go:
http://www.haskell.org/haskellwiki/Programming_guidelines
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
:: [a - b] - a - [b]
mapF = flip f
Aren't higher order functions just dreamy... ? ;-)
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
implementers can move the
goalposts of 2. ;-)
In reality this may just foster a small set of horribly specialised
optimisers in the compilers, with little benefit for real-world usage. :-(
Cheers,
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
. This is a waste
of energy (CPU time, or whatever).
So whether it's *computationally* more valuable, I don't know. But I
find that it helps me to order my thoughts about what a problem *needs*.
Cheers,
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell
! ;-)
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Haskell too, but I'm not sure. Try
the last three?
Cheers,
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Quoth Joel Reymont, nevermore,
Are these two different Simons? :-)
I'm beginning to wonder if Simon is less a name and more a title,
meaning strong in the lambda force or somesuch. Let's hope they don't
go over to the dark side ;-)
--
Dougal Stanton
- Integer - Integer
--gcd = f . map (uncurry min)
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Well, nobody likes tainting their beautiful pure code with IO, so I
rewrote the Random module to take advantage of the latest research [1]:
module Random where
getRandom = 4
Cheers,
D.
[1] http://xkcd.com/c221.html
--
Dougal Stanton
Quoth [EMAIL PROTECTED], nevermore,
loop = do
and True True
and True False
and False True
and False False
For this construct to work you'd have to have 'and' as a monadic
function - let's say, for argument's sake, in IO. And because there are
no results being
Quoth Magnus Therning, nevermore,
I'm not sure how a functional recipe would look, maybe something like
this:
White_sauce is a combination of ... .
Chopped_onions is onions cut into small pieces.
White_sauce_with_chopped_onions is the combination of white_sauce and
chopped_onions.
Quoth Paul Moore, nevermore,
why a newcomer like me shouldn't do this - in many ways, it's better
to start with some examples from a newcomer's perspective (these are
the sort of things I found useful) to show the more experienced
people what we're looking for.
I agree with this. I think many
Quoth Bill Wood, nevermore,
foldl (\water dish - wash water dish) soapywater dishes :: [Dishes]
Finally, that doesn't work so well when there are constraints on the
order that the dishes are washed, for example when washing the cruddiest
dishes first while there are more suds.
Ah, but
Quoth Bulat Ziganshin, nevermore,
are you learned to write things in this way? in *my* school, we have
studied
f=(a*b+d)*2
Also there's the issue of variable substitution. It gets taught very
early on when algebra is introduced (at least in UK):
f = x + 3y and y = sqrt(4 + n)
= f = x
Quoth Doaitse Swierstra, nevermore,
digest.chew.eat.serve.cook.chop.pluck.kill $ chicken
we all have a definite feeling that after applying the functions, the
original object is no longer available, and the FP view does not feel
entirely natural.
Yes, that is true. I can sort of see
, my screen isn't wide enough for that kind of thing...
But, well done to the people responsible for the binary stuff. It looks
fab.
D.
--
Dougal Stanton [EMAIL PROTECTED]
http://brokenhut.livejournal.com
Word attachments considered harmful.
___
Haskell
f = add' 1
Prelude f 2
3
Is this what you wanted? Perhaps you tried this but mistyped something?
Regards,
D.
--
Dougal Stanton [EMAIL PROTECTED]
http://brokenhut.livejournal.com
Word attachments considered harmful.
___
Haskell-Cafe mailing list
, because it's
such a nice word ;-)
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
but
--libdir=DIR use base library location
suggests that it wants --libdir=../c_lib
instead of --libdir ../c_lib. Could this be the case? I'd like to
think it would parse them pretty much the same way but you can never be
sure...
D.
--
Dougal Stanton
in particular
although this may change when v3 comes out. Some may want an explicit v2
(like the Linux kernel) while others will want the anti-patent
protection which v3 intends to offer.
D.
--
Dougal Stanton
___
Haskell-Cafe mailing list
Haskell-Cafe
then this'll save you a wee bit of time. In
future I also hope to download licences where I can, straight into the
LICENSE file.
Full usage can be found in the README. I hope someone finds it useful.
Cheers, D.
--
Dougal Stanton
___
Haskell-Cafe mailing
The cabal setup recognises a small set of licences which I don't think
are well explained. I'm trying to put together a canonical list for
setting up new projects.
GPL: http://www.gnu.org/licenses/gpl.txt
LGPL: http://www.gnu.org/licenses/lgpl.txt
Thankfully the FSF are particularly anal^W
Quoth Nicola Paolucci, nevermore:
Prelude :t liftM2
Prelude liftM2 :: (Monad m) = (a1 - a2 - r) - m a1 - m a2 - m r
Can someone help me understand what's happening here ?
What does a Monad have to do with a simple subtraction ?
What is actually the m of my example ?
I'm honestly not sure
Quoth Bulat Ziganshin, nevermore,
while i personally prefer to read source code and fascinated with
quality of code documenting in your lib, most peoples prefer to read
Haddocks, which again should be made available on web
I just thought I should point out, cos there appears to be some
compliant *.cabal file?
D.
--
Dougal Stanton [EMAIL PROTECTED]
http://brokenhut.livejournal.com
Word attachments considered harmful.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
colour should my bike shed be? ;-)
D.
--
Dougal Stanton [EMAIL PROTECTED]
http://brokenhut.livejournal.com
Word attachments considered harmful.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Quoth Donald Bruce Stewart, nevermore,
Ok, done!
Hehe, you can't leave this community alone for a second... Oh well,
that'll teach me to volunteer for something and then take a few hours
away from the computer! ;-)
D.
___
Haskell-Cafe mailing list
(although obviously much more succinct and
orders of magnitude clearer)
map (f') xs
where f' = \x - f (g (h x))
Cheers,
D.
--
Dougal Stanton [EMAIL PROTECTED]
http://brokenhut.livejournal.com
Word attachments considered harmful.
___
Haskell-Cafe
'let ...' wherever it feels?
It seems to work occasionally for me but then just hangs, so I thought
this might be the problem.
Cheers,
D.
--
Dougal Stanton [EMAIL PROTECTED]
http://brokenhut.livejournal.com
Word attachments considered harmful
Quoth Magnus Therning, nevermore,
I've been staring my eyes out trying to find a function that converts a
string into a ClockTime or CalendarTime. Basically something like C's
strptime(3). I can't seem to find anything like it in System.Time,
there are function that convert _to_ a string,
101 - 186 of 186 matches
Mail list logo