[Haskell-cafe] haskell flickr bindings: invalid signature when uploading

2010-12-10 Thread Dougal Stanton
I've mailed the maintainer of the flickr api package but thought I
would see if other people had this experience too. Google doesn't
reveal many people using this package as far as I can tell.

In short, authentication works fine but uploading images fails with
this message. This happens with the included examples/Uploader.hs as
well as my own code.

toRequest: POST request contains 1 files; unable to represent as query string
Defaulting to multiform/form-data instead
Flickr error:

 Code: 96
 Type: Flickr API error
 Details: Invalid signature

I haven't had a chance to dive deeper into this yet, but any advice
gratefully received.

Cheers,


D
-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskell flickr bindings: invalid signature when uploading

2010-12-10 Thread Dougal Stanton
Yes, that seems to be the reasonable assumption though I can't find
any good changelogs for the api. Further investigation will have to
wait until after the weekend :-)

Cheers,

D

On Fri, Dec 10, 2010 at 12:51 PM, Stuart Dootson
stuart.doot...@gmail.com wrote:

 On 10 Dec 2010, at 12:39 PM, Dougal Stanton dou...@dougalstanton.net wrote:

 I've mailed the maintainer of the flickr api package but thought I
 would see if other people had this experience too. Google doesn't
 reveal many people using this package as far as I can tell.

 In short, authentication works fine but uploading images fails with
 this message. This happens with the included examples/Uploader.hs as
 well as my own code.

 toRequest: POST request contains 1 files; unable to represent as query string
 Defaulting to multiform/form-data instead
 Flickr error:

 Code: 96
 Type: Flickr API error
 Details: Invalid signature

 I haven't had a chance to dive deeper into this yet, but any advice
 gratefully received.

 Cheers,


 D
 --
 Dougal Stanton
 dou...@dougalstanton.net // http://www.dougalstanton.net

 That wouldn't surprise me - I have a suspicion the Flickr API has changed 
 since hs-flickr was released - certainly there are issues with things like 
 getting full comment information out, for which I've made some mods within a 
 local copy of hs-flickr, with a mind to push them sometime.

 Stuart Dootson



-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] who's in charge?

2010-10-27 Thread Dougal Stanton
2010/10/27 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com:
 2010/10/27 Günther Schmidt gue.schm...@web.de:
 Hi all,

 this may be an odd question to some, but I think it's actually quite an
 un-extraordinary one.

        Who's in charge?

 Of Haskell I mean. If there was some alien from Planet Java to land on
 Planet Haskell and demand to be taken to our leader, whom would we take him
 to?

 The Haskell' committee?

They're just figureheads for a shadowy cabal :-D



-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Ed Lambda: Functional programming meetup in Edinburgh

2010-08-30 Thread Dougal Stanton
Looks good! I shall try to make it along. I'll have just come from my
SICP study group at that point so will want some statically typed chat
to soothe the pain :-)


D

On Mon, Aug 30, 2010 at 9:00 PM, Ollie Saunders
oliver.saund...@gmail.com wrote:
 Hi guys,

 I'm running a meetup for functional programming in Edinburgh. The
 first one will be on the 13th of September at Malone's Irish Bar (14
 Forrest Road) and will continue every 2nd monday of each month. For
 the first meetup I think we'll just be having a chat and getting to
 know each other but I hope to be able to expand it to talks and coding
 dojos once we have some regular numbers.

 For more details: http://meetup.com/ed-lambda/
 And we're on Twitter: http://twitter.com/ed_lambda
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] gd on Win32

2010-07-22 Thread Dougal Stanton
On Fri, Jul 2, 2010 at 8:34 PM, Christopher Done
chrisd...@googlemail.com wrote:


 That sounds like a good idea. I've setup a repo, I've merged in the
 latest work I did on it, and I've just updated it to be latest
 Prelude/base and to comply with -Wall. I'm just going to make it
 consistent with tibbe's style guide[1] before we start patching it for
 feature updates, so that we're singing from the same hymn sheet and
 then I'll let you you here. The Github repo is here:

 http://github.com/chrisdone/gd

Excellent news! I submitted some patches to the maintainer a while
back but never heard any response, positive or negative.

My changes were a subset of what you have on github now. It's great to
see it being cared for again!

Cheers,

D
-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [Newbie] What to improve in my code

2010-07-19 Thread Dougal Stanton
On Mon, Jul 19, 2010 at 9:24 AM, David Virebayre
dav.vire+hask...@gmail.com wrote:

 A minor point: instead of removing the punctuation, you maybe should
 convert it to whitespace.

 Otherwise in texts like there was a quick,brown fox (notice the
 missing space after the comma) you'll have the word quickbrown
 instead of 2 words quick and brown.

If you remove punctuation you

- run the risk of joining two valid words into one invalid word:
  quick,brown - quickbrown

- run the risk of converting one word into a different word:
 can't - cant
 won't - wont

If you split at punctuation you create more semi-words:
 can't - can, t
 shouldn't - shouldn t

It might be better regarding in-word apostrophes as letters in this case?

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: cabal: other-modules

2010-04-15 Thread Dougal Stanton
On Thu, Apr 15, 2010 at 1:49 PM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 Johannes Waldmann waldm...@imn.htwk-leipzig.de writes:
 What happened was this:
 I still don't see why this other-modules is needed.
 Ok, I understand the technical reason that cabal
 does not do dependency analysis but morally, it should?

 Why are people suddenly using the term morally when they mean why
 doesn't this do what I think it should?  None of its definitions seem
 to match what you mean:
 http://wordnetweb.princeton.edu/perl/webwn?s=moral

The proper use of words isn't dictated by what is found in small
dictionaries but by the speakers of the language. Also I would caution
against the judgement 'sudden' if you haven't done a corpus check: the
recency illusion can be a real pain.

'Morally' seems just the perfect word for this occasion --- concerned
with right or proper conduct. In this case, potential discrepancies
between the files that cabal 'knows' about when issuing different
commands; or the sense of deceit when it 'appears' to work only for
faults to appear further down the line.

I would guess this is just something we have to live with if cabal
can't be expected to include its own parser  dependency chaser.

Documentation is always a good first step though :-)

Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] developing against privately patched libraries, and cabal

2010-03-23 Thread Dougal Stanton
On Tue, Mar 23, 2010 at 10:00 AM, Roel van Dijk vandijk.r...@gmail.com wrote:
 The documentation for Data.Version might be insightful:

 http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-Version.html

 If Cabal uses the parseVersion function to parse versions then the
 following version is valid: 1.2.3-a-b-c. If should result in this
 value:

 Version {versionBranch = [1,2,3], versionTags = [a, b, c]}

 But I don't know if Cabal allows you to depend on such a version.


This post has an answer, but not one that makes me very happy ;-)

http://www.mail-archive.com/cabal-de...@haskell.org/msg05955.html

We've not yet removed tag from the parser for backwards compatibility.
Clearly what we should do is add a big warning (or simply error) that
such tags are no longer supported.

I hope in time to get Data.Version changed to eliminate the tags
entirely. (Duncan Coutts)

I guess it's too easy to abuse (says he who was planning to abuse it)
but it's sad that there isn't something I can easily use in its place.

At the moment renaming the package is serving my purpose.

Cheers,

D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Hackape package lackage

2010-03-22 Thread Dougal Stanton
Hackage seems to be down again.

$ cabal update
Downloading package list from server
'http://hackage.haskell.org/packages/archive'
^Ccabal: interrupted

$ ping -c3 hackage.haskell.org
PING abbot.galois.com (69.30.63.204) 56(84) bytes of data.

--- abbot.galois.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2012ms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] developing against privately patched libraries, and cabal

2010-03-21 Thread Dougal Stanton
If you're making local changes against a library you don't own (with
the ultimate intention of sending those changes back upstream to the
library maintainer) it makes sense change the version number to avoid
clashes with the canonical version of the library.

Of course, it's easy to lose track and end up publishing your own
program against a non-existent (outside your hard disk) version of the
library. I'd like to make it very obvious, both in mypogram.cabal and
library.cabal that one is a patched copy and the other has to be
compiled against a patched copy.

Does cabal provide any way of marking a version private? I thought
initially to just mark the version field in the patched library as
X.y-dougal and enforce my program to compile against that, but it
doesn't seem to recognise the -dougal suffix there.

Thoughts?

D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] developing against privately patched libraries, and cabal

2010-03-21 Thread Dougal Stanton
On Sun, Mar 21, 2010 at 5:15 PM, Leon Smith leon.p.sm...@gmail.com wrote:
 As somebody who's hacked on cabal-install a bit  (but don't have a
 worthwhile patch to contribute (yet?)),  I can tell you that versions
 support a tag structure,  at least internally,  but I haven't seen a
 non-empty tags field and don't know how to make the tags field
 non-empty.   For that I'd have to go source-code diving again.

 http://www.haskell.org/ghc/docs/latest/html/libraries/Cabal-1.8.0.2/Distribution-Version.html

That seems just the kind of thing that could be co-opted to my
purposes, but as you say the cabal file format doesn't seem to mention
how I'd go about setting my tag field. Trying Tag: dougal1 didn't
work, as I suspected ;-)

In the mean time I will try Stephen Tetley's approach of renaming the
package instead of the version.

Cheers,


D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the meaning of tilde (~) symbol

2010-02-14 Thread Dougal Stanton
 And, I've search the meaning of the symbol ~, but I've found nothing about
 this (note that's not easy to search ~ on google ...)

Searching for haskell tilde produces a lot of results and they're
all relevant (on the first page at least).



D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is Haskell a Fanatic?

2009-12-04 Thread Dougal Stanton
On Fri, Dec 4, 2009 at 6:36 AM, Evan Laforge qdun...@gmail.com wrote:
 I'd just like to point out or reiterate the odd rise in trolling and the
 recent announcements of haskell-2010...

 Just wait until haskell-2012 is announced with nonexistential aka
 eschatological types spelled notany a. World.

 It evaluates to a new form of bottom that blackholes the entire world...

I hear prototypes are already being used at the LHC for this very
purpose. Well-typed doomsday machines can't go wrong ;-)


D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Typefuck: Brainfuck in the type system

2009-11-19 Thread Dougal Stanton
On Thu, Nov 19, 2009 at 10:47 AM, Cristiano Paris fr...@theshire.org wrote:
 On Mon, Nov 16, 2009 at 6:26 PM, Gwern Branwen gwe...@gmail.com wrote:
 ...
 Too late:
 ...
 http://hackage.haskell.org/package/loli

 What's the point with loli?

Mrs Lopsided has all the loli.


D
-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to use bracket properly ?

2009-10-19 Thread Dougal Stanton
On Mon, Oct 19, 2009 at 9:18 AM, Ketil Malde ke...@malde.org wrote:
 zaxis z_a...@163.com writes:

 winSSQ count noRed noBlue = do
     let yesRed =  [1..33] \\ noRed
     let yesBlue = [1..16] \\ noBlue
     bracket (openFile ssqNum.txt WriteMode) (hClose) (\hd1 - pickSSQ
 count yesRed yesBlue hd1)

 It works very well. However, as i am used to C style so i want convert it
 into

 winSSQ count noRed noBlue = do {
     let yesRed =  [1..33] \\ noRed;

                            ^^^     ^
 Didn't you just comment out your semicolons?

Hi Ketil,

That's the first thing I thought when I read this code, then I
realised those aren't comment delimiters in Haskell! :-)

D



-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Hackage down

2009-10-19 Thread Dougal Stanton
Has not been responding for at least the last 12 hours.

Is there somewhere to look for status reports on sysadmin details like
this, so we can tell if

- it's a scheduled down time
- it's a problem but the admins know about it
- etc etc.

D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Examples/docs for simulated annealing bindings

2009-10-15 Thread Dougal Stanton
I found the HsASA library [1] on Hackage, but there's no documentation
and it's not particularly intuitive. I can't see any obvious way of
choosing initial config or generating new configurations. Google
reveals no one using it. Does anyone have ideas?

[1]: http://hackage.haskell.org/package/HsASA-0.1


Cheers,

D
-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Debugging Haskell code

2009-09-29 Thread Dougal Stanton
On Sun, Sep 27, 2009 at 9:17 PM, Paul Moore p.f.mo...@gmail.com wrote:


 That's odd, it seems to be saying it's not installed at all! Hmm, no -
 I did a cabal install --user (because Vista doesn't let me do
 site-wide installs), looks like cabal list doesn't pick up user
 installs.

 Hmm, cabal install mersenne-random --user didn't do anything, but
 cabal install mersenne-random --user --reinstall did reinstall it, and
 now it seems to work.

To find out what GHC picks up automatically:

$ ghc-pkg list
/home/dougal/lib/ghc-6.10.3/./package.conf:
Cabal-1.6.0.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0,
base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, containers-0.2.0.1,
directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3),
(dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3),
(dph-seq-0.3), extensible-exceptions-0.1.1.0, filepath-1.1.0.2,
(ghc-6.10.3), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3,
haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1,
mtl-1.1.0.2, network-2.2.1, old-locale-1.0.0.1, old-time-1.0.0.2,
packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1,
pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1,
regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3,
rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1,
time-1.1.3, unix-2.3.2.0, xhtml-3000.2.0.1
/home/dougal/.ghc/i386-linux-6.10.3/package.conf:
HTTP-4000.0.4, X11-1.4.5, X11-xft-0.3, benchpress-0.2.2.3,
cairo-0.10.1, colour-2.3.0, cpphs-1.9, darcs-2.2.1,
data-default-0.2, diagrams-0.2, gd-3000.4.0, gio-0.10.1,
glib-0.10.1, gtk-0.10.1, hashed-storage-0.3.7, haskeline-0.6.1.6,
haskell-src-exts-1.1.4, hscolour-1.15, mmap-0.4.1, soegtk-0.10.1,
split-0.1.1, svgcairo-0.10.1, tagsoup-0.6, terminfo-0.2.2.1,
terminfo-0.3.0.2, uniplate-1.2.0.3, utf8-string-0.3.4,
xmonad-0.8.1, xmonad-contrib-0.8.1, zlib-0.5.0.0, zlib-0.5.2.0

You should get everything hanging about, installed system-wide or in
your home directory. I assume this works much the same for Windows.

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Edinburgh Hackathon (Hac7) summary

2009-09-27 Thread Dougal Stanton
It's been nearly a month now since the Edinburgh Hackathon (29  30
August), organised to coincide with the convergence of Haskellers
arriving for the ICFP. My apologies for this very late summary!

Eric Kow was the driving force behind this Hackathon, though I agreed
to help out locally because I live in Edinburgh. We had trouble
organising a good venue through a combination of university holidays
and Edinburgh International Festival. We spent the first day camping
out in a cafe. On the second day Graeme Hutton arranged for us to use
an empty room in the bowels of the ICFP venue.

If I remember well the first day was heavily Darcs-oriented, and there
were interesting conversations on version control representation,
conflicts, and the future of Darcs over breakfast. The staff at
Henderson's Restaurant didn't seem to mind our impromptu geeky
enclave, and we kept buying coffee to pay for our wifi usage.

I'll let the other Haskellers explain in their own words what they
were up to for the rest of the time. Maybe some of them have updates
on where these projects have gone since then?


At the hackathon I started working on a small extension to the GHCi
debugger.  The goal of the extension is to allow the debugger to show
the term representation of thunks where possible. Presently, to find
out the value of a thunk in the debugger you must force its
evaluation. However, this is not always desirable, especially if the
thunk contains breakpoints, or if it diverges. In some cases it ought
to be possible to extract source code information from a thunk and
show that to the user. I didn't get very far in the implementation
because I spent most of the time re-learning how the term printer in
the debugger works (and chatting to other people).

-- Bernie Pope


I was continuing to work on my camp correctness proofs. In
particular, investigating how best to handle symmetric lemmas, and
refactoring the existing definitions and proofs.

-- Ian Lynagh


I worked on fixing Solaris/SPARC port of GHC. It turned out to be a
tedious header file related issue, not very interesting.

-- Ben Lippmeier


I worked on the formlets (again), I released a version that doesn't
add any functionality, it only solves a bug.

-- Chris Eidhof


I worked on a feature to let darcs users more conveniently upgrade to
the hashed repository format.  I also had lots of interesting
discussions with darcs users and hackers :-)

-- Eric Kow


I worked on analysing some darcs performance problems, fixing a
couple of GHC bugs, and some discussion about packages.

-- Simon Marlow

I (along with Benedikt Huber) worked on adding a 'cabal init' command
which automates much of the work of cabalising a project (creating a
.cabal file, a Setup.hs file, a LICENSE file, etc).  It's not quite
done yet but should be finding its way into the cabal-install HEAD
soon!

-- Brent Yorgey


I worked on the new hackage-server a bit.

   darcs get http://code.haskell.org/hackage-server/

live instance at http://sparky.haskell.org:8080/;

-- Duncan Coutts


Thanks everyone who took part and who supplied an elegant summary of
their work that weekend. I hope you all had a good time!

Cheers,

D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Edinburgh Hackathon round-up

2009-08-31 Thread Dougal Stanton
Hello Haskellers,

On Saturday  Sunday (28th  29th August) we held a Hackathon in
Edinburgh, before the ICFP got fully underway. If you were there,
thank you for coming.

We'll be writing a summary of what happened soon, and we'd love to
hear what you did. If you started a new project or fixed some
insidious bug, identified a major bottleneck or just enriched the
testing structure around your chosen project, it would be great to
know. Just a line or two is all we need!

I am hoping that everyone who attended will see this message, as they
must have seen Eric's original advertising emails. But please pass
this message along if you know there's someone we missed.

Cheers,

Dougal

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Dougal Stanton
On Fri, Jul 17, 2009 at 4:38 PM, Conor
McBrideco...@strictlypositive.org wrote:

 class Private x where

 public :: (forall x. Public x = x - y) - y
 public f = f Pike

 data Pike = Pike
 instance Private Pike
 instance Public Pike

 --

 But if I don't tell 'em Pike, I've ensured that
 blah can only be used in the argument to public.

Well I appreciated this bit even if no-one else did! :-) Also, that's
a nifty trick if it works!


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell Zippers on Wikibooks: teasing! :)

2009-07-16 Thread Dougal Stanton
On Thu, Jul 16, 2009 at 12:11 PM, Heinrich
Apfelmusapfel...@quantentunnel.de wrote:

   Generic Programming: An introduction
   http://www.cse.chalmers.se/~patrikj/poly/afp98/

 It's a bit verbose at times, but you only need the first few chapters to
 get an idea about polynomial functors (sums and pairs) and  mu .

Thanks, that's a really nice introduction, which seems to be at just
my level for the moment! :-)

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Colour tutorial (Was: AC-Vector, AC-Colour and AC-EasyRaster-GTK)

2009-07-10 Thread Dougal Stanton
On Fri, Jul 10, 2009 at 6:42 AM, rocon...@theorem.ca wrote:
 On Thu, 9 Jul 2009, rocon...@theorem.ca wrote:

 You can use by lib without worrying about the CIE.  You can use my library
 without ever importing or using the word CIE.  However, the CIE stuff is
 there for those who need it.

 Perhaps I (maybe with some help) need to make a tutorial on the haskell
 wiki to try to make it less intimidating.

 Okay, I threw together a quick introduction at
 http://www.haskell.org/haskellwiki/Colour.  Any changes, comments,
 corrections, and addtions are welcome.  It's a wiki!

Excellent!

I admit to being Quite Baffled by the new terminology when I tried
using this library a few months ago. Spent a lot of time on WP trying
to find out what everything was! Even something as simple as stating
yes, just use Colour Double makes the library seem a lot easier to
plumb in to other things.

A couple of notes:

Section 4.2: Out of gamut channels be clamped to either to the range
0 to 255 -- some kind of mix-up here

Section 5: Note that\n\nOne should avoid dissolving has a spurious
line break, or an unfinished sentence.

Cheers,

D


-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-06-30 Thread Dougal Stanton
On Tue, Jun 30, 2009 at 11:39 PM, John Meachamj...@repetae.net wrote:


 (+) seems to imply to me that the operator is non-associative. Something
 like () or (+) would be better.


It's too similar to the applicative (*), and implies all sorts of
things like different types of the two arguments and so on.


D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Edinburgh Haskell users meeting this afternoon

2009-06-21 Thread Dougal Stanton
Hello Haskell users

If you're in the Edinburgh (Scotland!) area and interested in Haskell
we may have just the thing for you.

I will be meeting one other Haskell Cafe list member at Doctor's pub
at 4pm this afternoon (Sunday 21 June). This could be the start of
something bigger, so if you're interested in Haskell please drop in
and swell the numbers. The conversation will probably be about some of
the basics - what is currying? what are typeclasses? what does the
deriving keyword do? - so don't feel nervous about being out of your
depth!

If I can get a table, I will try to display a copy of Hudak's _Haskell
School of Expression_ prominently. Please come up and say hello, or
fire me back a note if you can't make it but are still interested in
making this a regular meeting. Don't be shy about joining us if you're
available though!


Thanks everyone!


Dougal

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell Meetup groups in Glasgow

2009-06-13 Thread Dougal Stanton
On Sat, Jun 13, 2009 at 5:09 AM, A Smithasmith9...@gmail.com wrote:
 Do any Haskell Meetup groups exist in or around Glasgow, an informal
 get-to-gether in a pub,cafe or wherever ?
 I'm in Edinburgh, and on my own have been desperately trying to rewire my
 brain from Perl to Haskell without much success for most of this year. I
 posted  the meetup group question a few weeks ago for Edinburgh but got no
 response.

Sorry, I didn't see your Edinburgh message. I am also in Edinburgh and
though I don't know of any Haskell meet-ups I don't think it would be
hard to get critical mass for one. Edinburgh Uni teaches it to the
first years (AFAIK), Philip Wadler works here, and the ICFP and
Haskell Symposium are going to be held here later in the year. There
must be more than just the two of us! :-)

Cheers,

D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] I have forgotten .. my bad

2009-05-15 Thread Dougal Stanton
On Fri, May 15, 2009 at 5:30 AM, Vasili I. Galchin vigalc...@gmail.com wrote:
 Hello,

    darcs get --init ?? I want to pull down Data.FiniteMap. I
 have forgotten the path to Hackage .. I tried 

  sudo darcs get http://hackage.haskell.org/ Data.FiniteMap
 [sudo] password for vigalchin:
 Invalid repository:  http://hackage.haskell.org

 darcs failed:  Failed to download URL
 http://hackage.haskell.org/_darcs/inventory : HTTP error (404?)

 ??

 Obviously the code I am cabalizing needs to be upgraded(i.e. not using
 deprecated packages) but first I want it to build!

If you want to install something from Hackage, use

$ cabal install foo

If you want to grab the source

$ darcs get --partial path/to/repo

(Omit the --partial flag if you want the full source tree, but if
you're not intending to do serious work on the source it's probably
not worth it.)

From the error message above you appear to be darcs getting the root
directory of the hackage server, which isn't a valid repository.

Cheers,

D

-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANN: #haskell-in-depth IRC channel

2009-02-04 Thread Dougal Stanton
On Wed, Feb 4, 2009 at 5:32 AM, Benjamin L. Russell
dekudekup...@yahoo.com wrote:

 If neither #haskell nor #haskell-in-depth is appropriate,
 perhaps they would feel more comfortable in a
 Haskell-beginners-specific channel?

The danger with that is the only people who go there are beginners
looking for advice. Without advisers also, it would quickly wither.

How has the beginners' mailing list worked out, in this regard? At
least with a ML it's possible to set aside some part of the day to
answering questions... the same is not really possible for 5-hour-old
conversations on IRC.


Cheers,


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal list can't find Glob.cabal file?

2009-02-02 Thread Dougal Stanton
On Mon, Feb 2, 2009 at 12:01 AM, Duncan Coutts
duncan.cou...@worc.ox.ac.uk wrote:

 The solution is to upgrade:

 $ cabal install cabal-install

 $ cabal --version
 cabal-install version 0.6.0
 using version 1.6.0.1 of the Cabal library

Yes, this was the problem, despite me upgrading cabal-install before
mailing the list. Alas, an old cabal binary was being picked up from
/usr/local/bin.

Cheers for the help,


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] cabal list can't find Glob.cabal file?

2009-02-01 Thread Dougal Stanton
I get a curious message when trying to run 'cabal list':

$ cabal list

  omit some lines...
  ..
  Latest version available: 0.3
  Category: Network
  Synopsis: Pure bindings for the MaxMind IP database.
  License:  OtherLicense

cabal: Couldn't read cabal file ./Glob/0.1/Glob.cabal


Any ideas? As far as Hackage and the local index are concerned, 0.1
isn't even a recent version of Glob. Why should it be looking for the
file?

cabal-install version 0.5.1
using version 1.4.0.1 of the Cabal library



-- 
Dougal Stanton
dou...@dougalstanton.net // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-20 Thread Dougal Stanton
On Tue, Jan 20, 2009 at 3:42 PM, Heinrich Apfelmus
apfel...@quantentunnel.de wrote:

 Let me explain this monoid magic, albeit not in this message which would
 become far too long, but at

  http://apfelmus.nfshost.com/monoid-fingertree.html


That is a very nice summary! I did my own investigation of fingertrees
recently [1] and also came to the conclusion that the function names
for Monoid really are the ugliest, impractical things for such a
beautiful, simple concept.

Ah, if only we could go back in time :-)


[1]: 
http://www.dougalstanton.net/blog/index.php/2008/12/12/a-brief-look-at-fingertrees/


Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-16 Thread Dougal Stanton
On Thu, Jan 15, 2009 at 11:54 PM, ChrisK hask...@list.mightyreason.com wrote:


 So the original article, which coined 'Appendable', did so without much
 thought in the middle of a long post.  But it does show the thinking was
 about collections and there is one ONE instance of Monoid at

 http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Monoid.html#t%3AMonoid

 that is about a collection (Monoid ([] a)) that has a split operation.



The blind man at the back takes firm hold of the tail and says, But
why do we need to call it an *elephant*? No-one knows what that is.
Everyone knows what a rope is, so we should just call it a rope.

And that is how the elephant came to be labelled a rope in all the guide books.

:-)

Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt

2009-01-16 Thread Dougal Stanton
On Fri, Jan 16, 2009 at 1:23 PM, Philippa Cowderoy fli...@flippac.org wrote:
 On Thu, 15 Jan 2009, Lennart Augustsson wrote:

 If I see Monoid I know what it is, if I didn't know I could just look
 on Wikipedia.

 And if you're a typical programmer who is now learning Haskell, this will
 likely make you want to run screaming and definitely be hard to
 understand. We at least need a description that's aimed at people who
 probably don't consider themselves any flavour of mathematician, however
 amateur. One that, while giving the definition, concentrates significantly
 on intuition.

Wikibooks has a patchy book on Abstract Algebra which seemed quite
friendly to me (a non-mathematician and amateur FPer). I take it for
granted there will be parts I don't understand but if I just continue
to spot instances in the wild where they come up then it slowly
becomes obvious. Collecting examples of concrete monoids is fairly
easy fi you read some of the popular Haskell projects: Xmonad, Cabal,
etc.

I honestly don't see what all the fuss is about. No one's arguing that
more documentation is a bad thing. But some people seem to think the
mere existence of (a) technical terms or (b) technical terms not
invented by programmers are an affront.


Cheers,


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] some ideas for Haskell', from Python

2009-01-14 Thread Dougal Stanton
On Wed, Jan 14, 2009 at 3:12 PM, Neil Mitchell ndmitch...@gmail.com wrote:

 2) In Python it is possible to import modules inside a function.

   In Haskell something like:

   joinPath' root name =
   joinPath [root, name]
   importing System.FilePath (joinPath)

 Looks a bit ugly, but kind of useful. I'd make the syntax:

 joinPath' root name = joinPath [root,name]
  where import System.FilePath(joinPath)

 It does mean you need to read an entire file to see what functions it
 imports, but perhaps that is the way it should be. I could also
 imagine a syntax:

 joinPath' root name = import.System.FilePath.joinPath [root,name]

 i.e. doing an import and use at the same time.


This can be done with a fully-qualified name (or two). Not quite as
succinct, but I assume the scope of these imports is only local
anyway.

 joinPath root path = jp [root,filename path]
  where jp = System.FilePath.joinPath
filename = System.FilePath.takeFileName

or

 joinPath root path = System.FilePath.joinPath 
 [root,System.FilePath.takeFileName path]


Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] some ideas for Haskell', from Python

2009-01-14 Thread Dougal Stanton
 (defun avg (rest args)
   (/ (apply #'+ args) (length args)))

 Or as a macro like this:

 (defmacro avg (rest args)
   `(/ (+ ,@args) ,(length args)))

 The reason the macro is better is that the length of the list is known at
 compile time, so you don't need to traverse the list to calculate the length
 of the list.



I'm trying to work out how awesome the (+) operator is that you can
add the values together without needing to traverse the list ;-)


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Retrospective on 2008?

2008-12-11 Thread Dougal Stanton
On Thu, Dec 11, 2008 at 1:00 PM, Henk-Jan van Tuyl [EMAIL PROTECTED] wrote:

 Using the commands:
  cabal update
  cabal list | fgrep  *  | wc
 I counted 927 entries.


Unfortunately that's not a reliable means of determining cabal
packages. (Baffling, I know.) I think it actually lists things you
have installed from other sources, too. For instance:


$ cabal list | grep cairo
 * cairo
  Homepage: http://haskell.org/gtk2hs/archives/2006/01/26/cairo-eye-candy/
$ cabal install cairo
cabal: There is no package named cairo

Last time this came up there was mention of adding an option to only
list things which cabal has control over. I don't know if anything has
come of that idea.


Cheers,


D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] (no subject)

2008-11-25 Thread Dougal Stanton
2008/11/25 apostolos flessas [EMAIL PROTECTED]:
 hi,

 i am looking for someone to help me with an assignment!
 can anyone help me?

Hi Tolis!

Have a look at the homework help policy, so you know what people will
and will not answer.

http://www.haskell.org/haskellwiki/Homework_help


Then let us know what you're trying to do, and what your difficulty has been.


Cheers,


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] strange ghc output

2008-10-27 Thread Dougal Stanton
On Mon, Oct 27, 2008 at 4:49 PM, brad clawsie [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 i have a small program i have been using routinely that has stopped
 working. the last alteration of my install configuration was to upgrade
 the haskell-feed package as arch linux recommended. here is the error i
 get:

 - -
 $ runghc newspage.hs


 GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   fps_minimum
 whilst processing object file
   /usr/lib/bytestring-0.9.1.3/ghc-6.8.2/HSbytestring-0.9.1.3.o
 This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
 loaded twice.
 GHCi cannot safely continue in this situation.  Exiting now.  Sorry.
 - -

 i have reinstalled the haskell-bytestring package, to no avail.

 here is the actual code i am trying to run:

 http://hpaste.org/11514#a0

 its fairly straightforward. any clues?


Hi Brad,

This happens when, for example, your code imports a library which was
compiled with a previous version of bytestring. Replacing bytestring
on its own isn't enough to solve the problem. To make things more
awkward, it could be several libraries which use the old bytestring.
Using ghc --make, it seems this error can be ignored, but it's
annoying if you want to use the interactive GHC.

The only answer I know of is to systematically examine the
dependencies of each failing library as it is loaded in GHCi. Then
rebuild this library with the new bytestring and try again. This is
what I did in the end.

Maybe cabal-install provides more sophisticated features for this
nowadays; its development seems to be quite pacy!


Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Terminal-like Application Design

2008-10-17 Thread Dougal Stanton
2008/10/17 Magnus Therning [EMAIL PROTECTED]:

 I wanted to throw in another idea, something I didn't come up with
 myself but used in omnicodec[1].  Now I don't remember where I picked
 up the idea:

This method is described in
http://www.haskell.org/haskellwiki/High-level_option_handling_with_GetOpt.

I have used it in the past and eventually end up with huge Config data
structures and not much separation of unrelated parts of the
computation. Of course, this is probably just me ;-)

Alternatively (and this is where I have had more success) you can take
several passes over the command arguments, using different parsers.
Each parser just ignores what it doesn't recognise:

parseArgs names = do
args - getArgs
let info = parseWith infoOptions []
let options = parseWith argOptions defaultOptArgs
let query = parseWith queryOptions defaultQuery
return (info, options, query)
 where parseWith os z = case getOpt Permute os args of
(o,_,_) - foldr id z o

Note that this method tends to ignore user error at the command line,
but I'm sure a hybrid could be constructed that was more chatty but
still quite clean at the back end.

See http://www.dougalstanton.net/code/buses/ for this code in its
wider context.

Cheers,


D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] howto mix - within do?

2008-10-17 Thread Dougal Stanton
On Fri, Oct 17, 2008 at 1:39 PM, Larry Evans [EMAIL PROTECTED] wrote:
 do_with_assignment.proto.hs:30:2:
Couldn't match expected type `[]' against inferred type `IO'
  Expected type: [t]
  Inferred type: IO ()
In the expression: putStr v0=
In a 'do' expression: putStr v0=

Prelude let f = do { v - [999] ; return () }
Prelude :t f
f :: [()]
Prelude :t putStr 
putStr  :: IO ()


So v - [999] is in the list monad, but putStr is in the IO monad.
The two cannot mix in that way.

This looks like it might be homework so I'll refrain from saying any
more for now. Good luck!


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] List as input

2008-10-17 Thread Dougal Stanton
On Fri, Oct 17, 2008 at 2:21 PM, leledumbo [EMAIL PROTECTED] wrote:

 So, what's the solution? This one:

 (l::[Ord]) - readLn

 doesn't work (because Ord isn't a type constructor). It doesn't even comply
 to Haskell 98 standard. I want to be able to read any list of ordered
 elements.

I hope to be enlightened, but I'm pretty sure this is not possible.
Your readLn has to present a list of some specific type which can be
inferred at compile time. Which type is it? String? Int? Something
else?

Also, neither Show nor Read relate to Ord, so you cannot ever be sure
that all Readable/Showable types are Ordered, or that all Ordered
types can be Read/Shown.


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Libraries in home dir

2008-10-09 Thread Dougal Stanton
On Thu, Oct 9, 2008 at 2:08 PM, Mauricio [EMAIL PROTECTED] wrote:
 Hi,

 I want to use a few libraries from hackage
 and have already download and built them. Can
 I install those libraries somewhere in my
 home dir (I want to avoid installing as root)
 so that ghc can find them?

 If so, which options should I give to Setup.hs
 (with main=defaultMain) so that the libraries
 are going to be copy to that dir?

Dpeending on whether you have (and are using) cabal-install, either

$ cabal install diagrams --prefix=$HOME --user

or

$ runhaskell Setup.lhs configure --prefix=$HOME --user


That will (a) put the libraries etc in $HOME/lib and (b) register
these packages locally.

Hope that helps!


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OT: Haskell desktop wallpaper?

2008-10-08 Thread Dougal Stanton
2008/10/8 Magnus Therning [EMAIL PROTECTED]:
 This morning I got tired of my desktop wallpaper (one that ships with
 Debian's Gnome packages).  Typing haskell desktop wallpaper yeilded
 a lot of links to wallpapers with Colleen Haskell, while she's a
 beautiful lady it wasn't exactly what I was hoping to find.  Hence
 this email.  Where can I find some nice wallpapers inspired by
 Haskell, or maybe even created by Haskell code?

It shouldn't be too difficult to generate some wallpapers. Look at the
examples included with the Diagrams package [1]. You could take the
Ford circles and have different coloured circles at every startup. You
could even have a range of palettes depending on season ;-)


[1]: http://code.haskell.org/diagrams/example/examples.html


Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monad transformers [Stacking monads]

2008-10-07 Thread Dougal Stanton
On Mon, Oct 6, 2008 at 9:48 PM, Andrew Coppin
[EMAIL PROTECTED] wrote:
 Andrew Coppin wrote:

 I have some longwinded code that works, but I'm still thinking about how
 to do this more elegantly. It looks like what I really need is something
 like

  type M = StateT State (ResultSetT (ErrorT ErrorType Identity))

 Is that the correct ordering?

 If so, I guess that means I have to somehow construct ResultSetT. Is there
 an easy way to do that, given that I already have ResultSet? For example, if
 I put ResultSet into Traversable, would that let me do it?

 ...and again I'm talking to myself... :-/

 So after much experimentation, I have managed to piece together the
 following facts:

 - It appears that the outer-most monad transformer represents the inner-most
 monad. So StateT Foo ListT means a list of stateful computations, while
 ListT (StateT Foo) means a stateful list of computations.

Have you read Monad Transformers Step by Step [1] by Martin
Grabmueller? It's a fantastic introduction to these beasties, leading
the reader through a series of transformations from pure code to using
about 4 different monads/transformers for all sorts of extra features.

Seriously recommend it.

[]: http://uebb.cs.tu-berlin.de/~magr/pub/Transformers.pdf



Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell participating in big science like CERN Hadrian...

2008-10-03 Thread Dougal Stanton
2008/10/3 Galchin, Vasili [EMAIL PROTECTED]:
 Hello,

 One of my interests based on my education is grand challenge science.
 Ok .. let's take the  CERN Hadrian Accelerator.

 Where do you think Haskell can fit into the CERN Hadrian effort
 currently?

 Where do you think think Haskell currently is lacking and will have to
 be improved in order to participate in CERN Hadrian?

Is that the experiment where Picts are accelerated to just short of
the speed of light in order to smash through to the Roman Empire? ;-)

I don't know what the main computational challenges are to the LHC
researchers. The stuff in the press has mostly been about
infrastructure --- how to store the gigabytes of data per second that
they end up keeping, out of the petabytes that are produced in the
first place (or something).

Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flipped IO sequence

2008-10-01 Thread Dougal Stanton
2008/10/1 Cetin Sert [EMAIL PROTECTED]:
 warn :: String → IO Int
 warn = return 1  putStrLn-- causes an error
   -- = \msg → return 1  putStrLn msg -- works just fine
   -- = \msg → putStrLn msg  return 1 -- works just fine

 () :: Monad m ⇒ m b → m a → m b
 b  a = a = \_ → b

 Why do I get this compile-time error?? How can one define  ?

 [EMAIL PROTECTED]:~/lab/test/qths/p ghc -fglasgow-exts -O2 -o d64x --make
 demo2.hs system.hs
 [1 of 2] Compiling Netman.System( system.hs, system.o )

 system.hs:23:14:
 No instance for (Num (IO Int))
   arising from the literal `1' at system.hs:23:14
 Possible fix: add an instance declaration for (Num (IO Int))
 In the first argument of `return', namely `1'
 In the first argument of `()', namely `return 1'
 In the expression: return 1  putStrLn


This works for me (type signature added so GHCi doesn't choke)

Prelude let () = flip () :: IO b - IO a - IO b

And thus:

Prelude return 1  putStrLn yo
yo
1
Prelude

You might be having problems with the point-free code:

Prelude let warn' = return 1  putStrLn

interactive:1:24:
Couldn't match expected type `IO a'
   against inferred type `String - IO ()'
In the second argument of `()', namely `putStrLn'
In the expression: return 1  putStrLn
In the definition of `warn'': warn' = return 1  putStrLn

Adding in variable names straightens that out for me:

Prelude let warn s = return 1  putStrLn s
Prelude warn help
help
1
Prelude


Cheers,


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] csv one-liner

2008-09-30 Thread Dougal Stanton
2008/9/30 wman [EMAIL PROTECTED]:
 I got asked how to do one particular thing in excel, which led to discssion
 with our local MSOffice expert.
 During the discussion I stated that's it too much of a PITA and that I'd
 rather write a script.
 Long story short, I promised him a one-liner to show the power and beauty
 of Haskell.

 I got the csv package from hackage, modified the parseCSVFromFile so it's
 returns IO CSV rather than IO (Either ParseError CSV), and finished with
 following code

 (writeFile output.csv) = (liftM printCSV $ liftM (map updateLine) $
 parseCSVFromFile input.csv)

 Is there room for improvement ?
 Could it still be made into one-liner without modifying the csv module (and
 without resorting to
 case parseCSVFromFile input.csv of { Left _ - []; Right x - x}
 kind of tricks) ?


I have good news for you:

either :: (b -c) (a - c) (Either b a) - c

That type signature is from memory, but you get the idea. You pass in
two functions - one to deal with the Left and the other to deal with
the Right, and it sorts out your result for you.

Cheers,

D


-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Code.haskell.org down

2008-09-29 Thread Dougal Stanton
On Mon, Sep 29, 2008 at 4:02 PM, Mitchell, Neil
[EMAIL PROTECTED] wrote:
 Hi,

 For me, it seems that code.haskell.org is down. Is this the case for
 other people as well?

 It seems code.haskell.org regularly looses connectivity for me :-(

 Thanks

 Neil

http://downforeveryoneorjustme.com/code.haskell.org sez:

 It's just you. code.haskell.org is up.

which I can confirm from independent investigation ;-)

(Seriously though, the above site is a great tool for such circumstances.)



D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hmm, what license to use?

2008-09-26 Thread Dougal Stanton
On Fri, Sep 26, 2008 at 11:17 AM, Thomas Davie [EMAIL PROTECTED] wrote:

 Should you decide not to give someone something based on the fact that you
 either don't like them, or don't like what they'll do with the thing you
 give them.

That rather depends what you intend to give, doesn't it? :-)

Though the analogy is inapt, because the GPL *doesn't* prevent use of
software for things you don't like:

http://www.gnu.org/licenses/gpl-faq.html#NoMilitary

Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hmm, what license to use?

2008-09-26 Thread Dougal Stanton
On Fri, Sep 26, 2008 at 11:32 AM, Thomas Davie [EMAIL PROTECTED] wrote:

 Sure it does -- it prevents the use of software for things that are closed
 source.

Thing that are closed source is not a use of software. Programs
don't become more or less capable of designing rockets or writing
subversive literature because the licence changes. The GPL provides an
identical number of restrictions in this case as the BSD licence.

Either way, the OP subscribes to the GPL ethic. Such arguments cloud
the real point of discussion --- which licence (if any) satisfies the
permanent freedom clause with some flexibility for linking?

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: The container problem

2008-09-26 Thread Dougal Stanton
On Fri, Sep 26, 2008 at 8:01 PM, Achim Schneider [EMAIL PROTECTED] wrote:


 But then you'll be happy to know that there's already Data.Stream.List,
 with more coming at the same speed as we can order pizza for dons.

 http://hackage.haskell.org/trac/ghc/ticket/915


I was hoping that ticket would reveal the delivery address that we had
to send pizza to, but instead it revealed that streams stuff is not
scheduled for inclusion until GHC 6.12. :-(

Cheers,

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Notes on the future of Haskell from ICFP

2008-09-26 Thread Dougal Stanton
On Fri, Sep 26, 2008 at 11:52 PM, Bryan O'Sullivan [EMAIL PROTECTED] wrote:
 Here's a writeup I posted from the conference floor this afternoon:

 http://www.serpentine.com/blog/2008/09/26/some-notes-on-the-future-of-haskell-and-fp/

That's a very ominous title for such a positive write-up! It's all
very exciting stuff.

Haskell: it may be avoiding success, but it's certainly quite popular. ;-)


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Packages

2008-09-23 Thread Dougal Stanton
2008/9/23 Cetin Sert [EMAIL PROTECTED]:
 Austin:

 Let's say I go and compile a library from sources and install it through
 Cabal.
 How can I update the binary version of the library Cabal installed after
 recompiling the library using newer/modified sources?

That should happen automatically with cabal-install if the version
number in the .cabal file has changed.

There doesn't seem to be a good way of forcing cabal-install to
recreate a build (eg, if you want to rebuild/reinstall with
profiling). I think you need to unregister the package manually first.
:-(

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] about openTempFile

2008-09-17 Thread Dougal Stanton
On Wed, Sep 17, 2008 at 1:17 PM, Manlio Perillo
[EMAIL PROTECTED] wrote:
 The Python tempfile module, as an example, implements a wrapper around
 mkstemp function that does exactly this, and the code is portable; on
 Windows it uses O_TEMPORARY_FILE flag, on POSIX systems the file is
 unlink-ed as soon as it is created (but note that the code is not signal
 safe - well, many functions in the Python standard library are not signal
 safe).

Something like:

 withTempFile :: String - ((FilePath, Handle) - IO b) - IO b
 withTempFile name action = do
 tmpdir - getTemporaryDirectory
 bracket
 (openTempFile tmpdir name)
 (\(fp,h) - hClose h  removeFile fp)
 action

I don't know if this has the safety requirements you mean?


-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Erroneous package listings in hackage?

2008-09-13 Thread Dougal Stanton
On Sat, Sep 13, 2008 at 1:51 AM, Duncan Coutts
[EMAIL PROTECTED] wrote:
 Perhaps for packages that are installed but not re-installable via Cabal
 (like cairo, base, ghc etc) it should say something. Do you have any
 specific suggestions?

Well that explains it then! I had no idea it listed stuff not
available from Hackage. I've been using `cabal list | grep foo` to
search for packages but that's obviously not optimal, it seems.

I don't know what would clarify the matter. An available from
Hackage: (yes/no) field? Or a flag to pass to `cabal list` to show
Hackage stuff only?

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Erroneous package listings in hackage?

2008-09-12 Thread Dougal Stanton
$ cabal update
...
$ cabal list | less
 ...
 * cairo
  Latest version installed: 0.9.13
  Homepage: http://haskell.org/gtk2hs/
  License:  BSD3
 ...
$ cabal install cairo
cabal: There is no package named cairo

I must admit I was surprised to see a gtk2hs module on Hackage, but
not half as surprised when I found it wasn't there after all...

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] packages and QuickCheck

2008-09-09 Thread Dougal Stanton
2008/9/9 Conal Elliott [EMAIL PROTECTED]:
 How do folks like to package up QuickCheck tests for their libraries?  In
 the main library?  As a separate repo  package?  Same repo  separate
 package?  Keeping tests with the tested code allows testing of non-exported
 functionality, but can add quite a lot of clutter.

If they're in a separate package it's less easy to wire quickcheck
tests into the commit procedure.


Cheers,


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] packages and QuickCheck

2008-09-09 Thread Dougal Stanton
On Tue, Sep 9, 2008 at 2:05 PM, Dougal Stanton [EMAIL PROTECTED] wrote:

 If they're in a separate package it's less easy to wire quickcheck
 tests into the commit procedure.

And by package there, I mean repo. Obviously ;-)

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there GHC 6.8.3 on Ubuntu?

2008-08-28 Thread Dougal Stanton
On Thu, Aug 28, 2008 at 7:25 AM, Ketil Malde [EMAIL PROTECTED] wrote:


 If you want to pack 6.8.3, go for it!  If you just wanted to use it,
 I've had success using the binary snapshots on previous Ubuntus.


Agreed. The default Linux binary works fine for me in Hardy Heron,
just installed in my ~/bin.

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: problem with cabal for syb-with-class

2008-08-26 Thread Dougal Stanton
On Tue, Aug 26, 2008 at 2:22 PM, Duncan Coutts
[EMAIL PROTECTED] wrote:

 So when ghc finds that one of your modules needs to import something
 that is not in one of the given packages it says that it's in another
 package that is 'hidden'. Of course it's only hidden because Cabal told
 ghc to hide them.

Yes, it is one of those unfortunate error messages that says I know
what the problem is *and* how to fix it, but I'm not going to. ;-)

Cheers,

Dougal
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HTTP package: connection closing bug?

2008-08-21 Thread Dougal Stanton
On Thu, Aug 21, 2008 at 11:44 PM, Aaron Tomb [EMAIL PROTECTED] wrote:


 I've never looked into it deeply, but I just wanted to chime in that I've
 seen this, too.

I may be confusing it with something else, but I seem to recall
something very similar from a while back, in a blog post somewhere? I
can't remember the details, but someone was writing a server
application of some kind and came across a socket leaking error that
was a one-line fix line this. The description and the fix just seem so
familiar. :-\

Sorry, this is the most incoherent and useless post! Maybe someone
else has been paying more attention and can remember who it was, and
where.

Cheers,

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is www.haskell.org down?

2008-08-14 Thread Dougal Stanton
2008/8/14 Sean Leather [EMAIL PROTECTED]:
 I can't reach www.haskell.org , and I'm having withdrawal issues.


I also can't get any response from it. It's not just you!


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Alternatives to convoluted record syntax

2008-07-03 Thread Dougal Stanton
Hi Haskellers,

This is a style question, as my program works fine but looks really
ugly and can be confusing to maintain.

I take options from the command line using GetOpt and hand back this
structure for later use.

 data Opts = Opts
 { query :: Query
 , queryLimit:: Maybe Limit
 , disabledOnly  :: Bool
 } deriving Show

Here's a snippet from the parser for one option (others omitted for clarity):

 options :: [OptDescr (Opts - Opts)]
 options =
 [ Option b [bus] (ReqArg busNum NUM) Bus number
 , ...
 ]
   where busNum n os = let b = (query os) { queryBusNumber = Just n }
   in if isBusId n then os { query = b } else os

Variations on that ugliness are repeated four times for other fields.
Is there an alternative way to change the value of nested fields?

Thanks,

Dougal.

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Alternatives to convoluted record syntax

2008-07-03 Thread Dougal Stanton
On Thu, Jul 3, 2008 at 11:13 AM, Henning Thielemann
[EMAIL PROTECTED] wrote:


 infix2 :: ((Char, Int), String)
 infix2 =
   (('b',7),hallo)$%first^:second^=10

 (second^=10) replaces the second member of pair with a value.
 (^:) applies that change to the outer record (again a pair).
 ($%) applies the modifier (first^:second^=10) to a concrete pair.


Hmm! Thanks for the pointer, but I'm not sure that would really clear
things up much. It seems this may just be a wart I'll have to put up
with.

Cheers,

D


-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Call Graph Tool?

2008-06-27 Thread Dougal Stanton
On Fri, Jun 27, 2008 at 11:39 AM, Claus Reinke [EMAIL PROTECTED] wrote:
 If you wanted to go down that route, try using 'ghc --make -v2'
 and translate that dependency graph to dot.

Also, if you want to get a quick 'n dirty list of which of your own
files depend on which others, ghc -M $main.hs works quite well. I've
had some success in the past shoving this stuff almost directly into
the graph libraries and out to graphviz. Be warned that it fiddles
with any file called Makefile in your working directory...

Cheers,

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Polymorphic QuickCheck arguments

2008-06-17 Thread Dougal Stanton
2008/6/17 Hugo Pacheco [EMAIL PROTECTED]:
 Hi all,
 There is something about polymorphic tests in QuickCheck that I do not
 understand.
 If you write the simplest dummy test function
 tst :: a - Bool
 tst _ = True
 and evaluate it we get
 verboseCheck tst
 0:
 ()
 1:
 ()
 ...
 How come did the polymorphic value a get instanciated to ()? Is this done
 via the Testable type class?

I haven't got something here to check with, but from the formatting it
looks like every odd line is a randomly-chosen boolean value, and the
following line is the result? It might be just printing the result
value of IO (). Maybe try a more complete test to see how that looks?

Cheers,

D


-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Functional board games

2008-04-21 Thread Dougal Stanton
I'm having a go at making a functional board game (the back-end logic
for one, at least) and as with all good projects it raises lots of
questions. But I'll keep it to one this time.

Does anyone know of functional-style implementations of
chess/draughts/go/anything else that might give me ideas? I am writing
a game of Thud (yes, from the Terry Pratchett book...) but I don't
hold much hope of their being a functional-style Thud game already in
existence!

Cheers,

D.

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functional board games

2008-04-21 Thread Dougal Stanton
On Mon, Apr 21, 2008 at 5:08 PM, Ryan Ingram [EMAIL PROTECTED] wrote:
 Bertrand Felgenhauer[1] wrote a peg solitaire game[2] using Prompt[3]
  to interact with the user.

Thanks to everyone for the suggestions, particularly the Games page on
the Haskell wiki which didn't appear in all my googling atttempts.

Also, I had been hoping to have a go with Prompt after I saw it first
time round but couldn't remember what it was called! So thanks to Ryan
for bringing it up again.

Cheers,

D.


-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Markup bug in HaskellWiki

2008-03-04 Thread Dougal Stanton
On 04/03/2008, Henning Thielemann [EMAIL PROTECTED] wrote:

  In the Wiki article

http://haskell.org/haskellwiki/Comparison_chain

   there is the piece

unzipunzip

   which is improperly formatted.

I guess the wiki uses GeSHi, and it's because of a bug in the keyword
list. I reported it to the maintainer a few weeks ago (when I wrote
this [1]) but I haven't heard any word back. It's dead easy to fix if
someone has access to the PHP source.

There's a file called, IIRC, haskell.php with a large list of
keywords. Two of them, 'unzip' and 'unzip3' appear twice. Delete one
of each and it all works fine again.


[1] 
http://www.dougalstanton.net/blog/index.php/2008/02/12/spot-the-deliberate-mistake


-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Markup bug in HaskellWiki

2008-03-04 Thread Dougal Stanton
On 04/03/2008, Wolfgang Jeltsch [EMAIL PROTECTED] wrote:
 Am Dienstag, 4. März 2008 16:10 schrieb Dougal Stanton:
   […]


   There's a file called, IIRC, haskell.php with a large list of
   keywords. Two of them, 'unzip' and 'unzip3' appear twice. Delete one
   of each and it all works fine again.


 Why do they appear at all?  They are not keywords.

Well, keywords is a bit of a misnomer. Geshi isn't very smart, it just
recognises the standard prelude and adds in links to the online API.


D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: Leksah 0.1 - Haskell IDE written in Haskell

2008-02-14 Thread Dougal Stanton
On 14/02/2008, Alistair Bayley [EMAIL PROTECTED] wrote:

  I just downloaded this from hackage and went through the usual Cabal
  ritual. The build fails with
   
  Would I be better off getting straight from the darcs repo?

I compiled from the darcs repo last night, which worked fine.

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FP and Quality

2008-02-08 Thread Dougal Stanton
On 07/02/2008, Benjamin L. Russell [EMAIL PROTECTED] wrote:

 - text follows immediately after this line -
 Haskell vs. Ada vs. C++ vs. Awk vs. ... An Experiment
 in Software Prototyping Productivity (1994),
 by Paul Hudak and Mark P. Jones:
 http://citeseer.ist.psu.edu/41732.html

This one's quite interesting but refers to the much longer report. In
the bibliography it is listed as unpublished, but during the text the
authors suggest you read it anyway. Does anyone have a source for this
document. (A quick search has only produced further citations in other
places.)

J.A.N. Lee, B. Blum, P. Kanellakis, H. Crisp, and J.A. Caruso.
ProtoTech HiPer-D Joint Prototyping Demonstration Project, February
1994. Unpublished; 400 pages.


Cheers,

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hamming's Problem

2008-01-18 Thread Dougal Stanton
On 18/01/2008, Bertram Felgenhauer [EMAIL PROTECTED] wrote:

 I have some ideas, but maybe you want to work on a correct solution
 first?

There is an implementation on the wikipedia article for Haskell:

hamming = 1 : map (2*) hamming `merge` map (3*) hamming `merge` map (5*) hamming
 where merge (x:xs) (y:ys)
| x  y = x : xs `merge` (y:ys)
| x  y = y : (x:xs) `merge` ys
| otherwise = x : xs `merge` ys

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Dougal Stanton
Are the functions

 passall, passany :: [a - Bool] - a - Bool
 passall ps v = and $ map ($v) ps
 passany ps v = or $ map ($v) ps

or something similar defined anywhere? Such that one can write

 filter (passany tests) [0..10]
 filter (passall tests) [0..10]

where

 tests = [5, odd]

Or is there a better way of filtering by several predicates for each
value without using

 filter p3 . filter p2 . filter p1

or

 filter (\v - p1 v  p2 v  p3 v) vs

Cheers,

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Filter by several predicates at once

2008-01-17 Thread Dougal Stanton
On 17/01/2008, Stuart Cook [EMAIL PROTECTED] wrote:
 On Jan 18, 2008 1:46 AM, Isaac Dupree [EMAIL PROTECTED] wrote:

  nearly; using Prelude:
  passall ps v = all ($v) ps
  passany ps v = any ($v) ps

Yes, thanks Isaac. That should have been obvious, argh...


   passall = swing all
   passany = swing any

 Whether that's any better than the pointwise version is up to you.

I think in this case I will use the explicit version, because I
wouldn't remember how swing worked. What is the motivation for the
name? ;-) (Do I want to hear the answer...?)

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] type questions again....

2008-01-11 Thread Dougal Stanton
On 11/01/2008, Nicholls, Mark [EMAIL PROTECTED] wrote:

 Preferably illustrating it in terms of logic rather than lambda calculus.


 There's plenty of stuff out there on it….but most of it seems double dutch
 (no offense to the dutch intended).


I think the preferred idiom, considering the notation, is that it's
all Greek to me ;-)

D

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble with indentation

2008-01-09 Thread Dougal Stanton
On 09/01/2008, Fernando Rodriguez [EMAIL PROTECTED] wrote:

 However, ghc complains about: parse error on input `=' at the if m = 2
 then  line. I believe this is some sort of layout error.  Can someone point
 out what I am doing wrong?

Assuming the layout didn't get munged during the email process, the
problem is that the 'if' can't go there. You need to have 'sth = if
...' not 'if cond then sth = '

 diaDeSemana d m a = toEnum num :: DiaSemana
 where
 num = zeller x y z
 zeller x y z = (700 + (26 * x 
 - 2) `div` 10
 + d + y + y `div` 4 + 
 z `div` 4 - 2 * z)
 `mod` 7
 if m = 2 then
 x = m + 10
 y = (a - 1) `mod` 100
 z = (a-1) 'div' 100
 else
 x = m - 2
 y = a  `mod` 100
 z = a `div` 100

Maybe try:

 (x,y,z) = if m = 2
  then (m+10, (a-1)`mod`100, (a-1)`div`100)
  else (m-2 , a`mod`100, a`div`100)

I haven't tested this though

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why purely in haskell?

2008-01-09 Thread Dougal Stanton
On 09/01/2008, Yu-Teh Shen [EMAIL PROTECTED] wrote:
 I got question about why haskell insist to be a purely FL. I mean is
 there any feature which is only support by pure?

Have a look at the ueber-retrospective on Haskell, fifty-five pages of
all the history and motivation one could possibly want.

http://research.microsoft.com/~simonpj/papers/history-of-haskell/

It's interesting reading, I promise! ;-)

D.
-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hoogle works once more

2007-12-06 Thread Dougal Stanton
On 06/12/2007, Neil Mitchell [EMAIL PROTECTED] wrote:
 Hi,

 I've just finished updating Hoogle (http://haskell.org/hoogle/) to
 work with the latest GHC API, in particular all the base split that
 has occurred and the few functions that were added. It took rather
 longer than I would have liked, because of paper deadlines etc, but
 its now sufficiently automated that it should only take a few seconds
 next time the libraries move in new directions.

This is great news. Hoogle is a fantastic tool.

Is there a way to search on module names? If I put in Data.Map then
the one thing that doesn't come up is a link to the library page for
Data.Map. That would be a really good short-cut.

Once again, thanks.

Cheers,

D.

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Advice for clean code.

2007-12-04 Thread Dougal Stanton
On 04/12/2007, Felipe Lessa [EMAIL PROTECTED] wrote:

 I always thought show was meant for returning a String that could be
 used to recreate the original data if you copy-pasted it in your code
 or if you used read (i.e. read . show == id). Reading the
 documentation more carefully, I see that [1] says that this property
 holds for *derived* instances, and says nothing about it in the
 general case.

 So, what's the deal here? May I use Show for anything without breaking
 conventions? And how about Read?


That seems to be convention though I don't think it's required for the
correct operation of anything. Anyone?

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell code in Wordpress

2007-11-23 Thread Dougal Stanton
On 23/11/2007, Paulo J. Matos [EMAIL PROTECTED] wrote:
 Hi all,

 I'm curious about the best way to typeset haskell code in a wordpress
 blog. Using blockquote removes all indentation. :-(


There is a code highlighter for wordpress that works for Haskell code,
but it's a bit of a pain to use, especially with the visual editor.
It'll do a one-way conversion of  into gt; whenever you do a
preview. :-(

It's easy to use though.

pre lang=haskell
main = putStrLn yo lambda
/pre

Unfortunately WP isn't really great at handling text-preprocessors
like this or Markdown. To work properly they have to subvert the
system a bit.

D.

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Searched for mdo on haskell.org. Found nothing.

2007-11-22 Thread Dougal Stanton
On 22/11/2007, Richard Kelsall [EMAIL PROTECTED] wrote:

 Did I do something wrong when searching haskell.org?

You didn't use Google first? ;-)

Seriously though, using the search box at haskell.org seems to be a
dead loss. I'm sure this has come up in the past.

D.

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: The Monad.Reader Issue 9: SoC special

2007-11-19 Thread Dougal Stanton
On 19/11/2007, Wouter Swierstra [EMAIL PROTECTED] wrote:


 I am pleased to announce that a new issue of The Monad.Reader is now
 available:

http://www.haskell.org/haskellwiki/The_Monad.Reader

Thanks Wouter, the haiku look great! ;-)

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Renaming constructors for readability

2007-11-13 Thread Dougal Stanton
I wonder, is there an equivalent of the 'type' keyword for
constructors? An example:



-- create a pseudo-C pointer type
-- which can point to a value or a
-- null.
type Pointer a = Maybe a

-- int a = 3;
-- int *pa = a;
ampersand :: t - Pointer t
ampersand a = Just a

-- int b = *pa.
star :: Pointer a - a
star (Just a) = a
-- note this function behaves
-- in an 'authentic' fashion ;-)


To really complete the illusion it would be nice to replace the names
Just and Nothing with PointerTo and Null. Then the constructors would
really mean something. Is there a solution?

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Renaming constructors for readability

2007-11-13 Thread Dougal Stanton
On 13/11/2007, Henning Thielemann [EMAIL PROTECTED] wrote:

 On Tue, 13 Nov 2007, Dougal Stanton wrote:

  -- int a = 3;
  -- int *pa = a;
  ampersand :: t - Pointer t
  ampersand a = Just a

 What's bad about using 'ampersand' function as replacement for the
 constructor 'Just'?


I also wanted to use it in pattern matching but have the advantage of
all the stuff already written for Maybe. (Note this was an example I
made up on the spur of the moment anyway.) I'd often thought it would
be nice when adapting standard data structures for specific programs.
Like,

data Tree a = Leaf a | Branch a [Tree a]
data FS a = File a | Folder a [FS a]

Once you've got one it would be nice to repurpose it with more
appropriate names. Just an idea! :-)

D.
-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] words function

2007-11-08 Thread Dougal Stanton
On 08/11/2007, Ryan Bloor [EMAIL PROTECTED] wrote:

 hi

  I am trying to create a function that uses the words function... I am doing
 the same thing to each element in a list so I am using mapping techniques.

  Code...

   --Define the main first function
  rStrings2Results :: ([String] - String) - [[String]] - [String]
  rStrings2Results f(head:tail) = (f head : rStrings2Results f tail)

Your description of the problem doesn't relate to the type signature
or the solution you have here. I assume the function f which you pass
in is meant to be 'words'? In that case, the type signature should be
(String - [String]), not the other way round (which would be unwords,
or concat, for example).

The example solution as it stands also doesn't deal with the empty
list. The pattern match against [] will fail.

  I just want take a list and on the first member (hello my name is ryan)
 to say [(hello, my, name, is, ryan),..] using the
 words function.

I'm still not completely clear on what you want, so maybe you can
clarify. I guess it's something like:

[my name is ryan, i am learning haskell, it is fun] -
[[my,name, is, ryan],[i am learning haskell, it is fun]]

Is this about right? If so, then your type signature should be:

f :: (String - [String]) - [String] - [[String]]

Although as another poster mentioned, you might think about separating
out the head and the tail of the list. It seems to just be a
two-element list which could be easily represented as a tuple.

f' :: (String - [String]) - [String] - ([String], [String])

Of course I could be very wrong with my interpretation of your problem!

Cheers,

D.

-- 
Dougal Stanton
[EMAIL PROTECTED] // http://www.dougalstanton.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why can't Haskell be faster?

2007-10-31 Thread Dougal Stanton
On 31/10/2007, Peter Hercek [EMAIL PROTECTED] wrote:

 Anyway, if Haskell would do some kind of whole program analyzes
   and transformations it probably can mitigate all the problems
   to a certain degree.


I think JHC is supposed to do whole-program optimisations. Rumour has
it that its Hello World examples are the fastest around - I have heard
it has problems with larger code bases though. ;-) What's the current
state of play on this?

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] viewing HS files in Firefox

2007-10-27 Thread Dougal Stanton
On 27/10/2007, Isaac Dupree [EMAIL PROTECTED] wrote:
 When I try to go to one of the Module.hs files, e.g. on
 darcs.haskell.org, it now has type HS and Firefox refuses to display it
 (and only lets me download it).  Does anyone know how to make Firefox
 treat certain file types as others (HS as plain text, in particular)?
 so that I can browse them with any convenience

I've looked into this before but haven't found a satisfactory answer.
At best, you can get the offending MIME types to open in a third party
text viewer. But I don't know how to force the internal text viewer.

Actually, a thought occurs. The address bar prefix view-source: works
for html. As in, http://www.haskell.org; -
view-source:http://www.haskell.org;. This might be an effective
workaround though I don't have a page to test it on right now.

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Suspected stupid Haskell Question

2007-10-17 Thread Dougal Stanton
On 17/10/2007, Big_Ham [EMAIL PROTECTED] wrote:

 Is there a library function to take a list of Strings and return a list of
 ints showing how many times each String occurs in the list.

 So for example:

 [egg, egg, cheese] would return [2,1]

 I couldn't find anything on a search, or anything in the librarys.

 Thanks BH.

No, but it is also trivial to create, with the 'group' function in
Data.List. I'll stop there though, cos this could be a homework
question.

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Suspected stupid Haskell Question

2007-10-17 Thread Dougal Stanton
On 17/10/2007, Dougal Stanton [EMAIL PROTECTED] wrote:

 No, but it is also trivial to create, with the 'group' function in
 Data.List. I'll stop there though, cos this could be a homework
 question.

It's just occurred to me that answering questions like these is a bit
like the prisoner's dilemma.

 - If I give the full answer and no-one else does, then maybe I'm
doing someone's homework for them?
 - If I just give clues and someone else gives the answer, it makes me
look mean. :-(
 - If we all give the answer, everybody's happy and the blame (if it
was a set question) is spread around a bit.
 - If we all answer with vague hints then it makes the list as a whole
less useful and seem a bit arrogant.

There's no way to win! :-)

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: New slogan for haskell.org

2007-10-09 Thread Dougal Stanton
On 09/10/2007, Alex Tarkovsky [EMAIL PROTECTED] wrote:
 Brent Yorgey wrote:
  Aren't you going to make one featuring a catamorphism? =)

 Done, thanks for the contribution! ;)

Goes to look...

...oh, very impressive! ;-) Lolcats seem to have reached a terrifying new nadir.

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Very crazy

2007-09-25 Thread Dougal Stanton
On 25/09/2007, Andrew Coppin [EMAIL PROTECTED] wrote:

 Type signature is

   show_system :: [[Double]] - String

 It takes a matrix representing a system of equations, and pretty prints
 it. Unfortunately, doing complex formatting like that is... well,
 complex. The input is quite simple (it's a bunch of numbers), the output
 is quite simple (it's a neatly formatted string), but the process in the
 middle is... a mess. I'd like to find a more readable way of doing stuff
 like this. It's not just this specific function; any general hints would
 be good. ;-)

In this instance I would suggest:

(1) Text.Printf
(2) Pull out some of those things into separate functions with
where/let clauses.

If it's a matrix you should probably have something like

 showMatrix = concatMap showRow

Since you'll be applying the same procedures to each line of digits.

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How can I stop GHCi from calling show for IOactions?

2007-09-20 Thread Dougal Stanton
On 20/09/2007, Ryan Ingram [EMAIL PROTECTED] wrote:

 I think a more consistent behavior would be to not print the LHS at
 all.  If you wanted to print the result of the computation you could
 just do:

 Prelude bar 5

 or, if you also wanted bound variables afterwards:

 Prelude (x, Just y) - bar 5
 Prelude (x, Just y)

 Perhaps this is my imperative background speaking, but I don't see
 much difference at the GHCi prompt between these two:

 Prelude let x = 5
 Prelude x - return 5

I agree with this interpretation. If I want to just *do* the action,
I'll type it. If I want to *store* the action then I'll bind it to
something. That's the intuition I have, anyway. And it works for pure
functions:

Prelude let ns = [1..]
Prelude [1..]

The difference between those two feels like the difference between:

Prelude contents - readFile massive.txt
Prelude readFile massive.txt

But as Ryan mentioned, this may just be poor intuition from an overly
imperative mindset...

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] getting crazy with character encoding

2007-09-12 Thread Dougal Stanton
On 12/09/2007, Seth Gordon [EMAIL PROTECTED] wrote:

 I � Unicode.

Was it intentional that the central character appears as a little '?',
even though the aleph on the line above worked? Either way it would be
very amusing, but for different reasons...


D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can somebody give any advice for beginners?

2007-09-11 Thread Dougal Stanton
On 11/09/2007, Peter Verswyvelen [EMAIL PROTECTED] wrote:
 To me, Haskell was a bit like climbing a mountain which is largely
 covered by fog; you don't see anything until you've climbed high enough,
 and then the view is really beautiful ;-)

Either that or: the foothills are glorious, but as soon as you get
into the higher altitudes you can fall down a monad and not be able to
escape...

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dougal Stanton
On 06/09/07, Axel Gerstenberger [EMAIL PROTECTED] wrote:

 module Main where

 import System.IO
 import Text.Printf

 main :: IO ()
 main = do
  let all_results1 = take 2 $ step [1]
  --print $ length all_results1 -- BTW: if not commented out,
--  all values of all_results
--  are already
--  calculated here
  loop [1..50] $ \i - do
  let x = all_results1!!i
  putStrLn $ show i ++++ show x

 -- create an infinite list with values u_{n+1} ++ [u_n,u_{n-1},...,u_1]
 -- where u_{n+1} = f (u_n)
 step history =
  case history of
  []   - error no start values
  xs   - xs ++ (step [ f (head $ reverse (xs) )])

To create an infinite list where each f(u) depends on the previous u,
with a single seed value, use 'iterate':

Prelude let us = iterate f 3

That produces your infinite list of values, starting with [f 3, f(f3),
f(f(f 3)), ...]. Pretty neat.

Then all you really need is

main = mapM_ (uncurry (printf %d %f\n)) (zip [1..50] (iterate f 3))

You can probably shorten this a bit more with arrows but I've got a
cold at the moment and not really thinking straight.

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dougal Stanton
On 06/09/07, Axel Gerstenberger [EMAIL PROTECTED] wrote:

 however,I don't get it this to work. Is it possible to see the
 definition of the iterate function? The online help just shows it's usage...

The Haskell 98 report includes source for the standard prelude. Check 'em out...

http://www.haskell.org/onlinereport/standard-prelude.html



 Again thanks a lot for your ideas and the links. I knew there was a
 one-liner for my problem, but I couldn't find it for days.

That's a common feeling with Haskell, I think. ;-)

D
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dougal Stanton
On 06/09/07, Sebastian Sylvan [EMAIL PROTECTED] wrote:

 foo = 2 : 3 : zipWith f (drop 1 foo) foo

 There's also zipWith3 etc. for functions with more arguments.

I think this is called taking a good thing too far, but cool too:


f1 u = u + 1
f2 u v = u + v
f3 u v w = u + v + w

-- functions renamed for consistency)
zipWith1 = map
zipWith2 = zipWith

-- and hey presto!
us1 = 3 : zipWith1 f1 us1
us2 = 2 : 3 : zipWith2 f2 (drop 1 us2) us2
us3 = 2 : 3 : 4 : zipWith3 f3 (drop 2 us3) (drop 1 us3) us3

*Main take 10 us1
[3,4,5,6,7,8,9,10,11,12] -- integers from three upwards
*Main take 10 us2
[2,3,5,8,13,21,34,55,89,144] -- fibonacci
*Main take 10 us3
[2,3,4,9,16,29,54,99,182,335] -- what's this?

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Guihaskell and PropLang 0.1

2007-08-15 Thread Dougal Stanton
On 15/08/07, Asumu Takikawa [EMAIL PROTECTED] wrote:
 == GuiHaskell

 Guihaskell is a graphical REPL using PropLang, a GUI combinator library
 built on top of Gtk2hs, which aims to be an IDE for Haskell written in
 Haskell. It's still rough around the edges, so think of this as an alpha
 release. As such, I'd appreciate any feedback very much!

Looks interesting. I couldn't see anywhere whether it has any OS
dependencies. Is it cross platform?

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Dougal Stanton
On 14/08/07, Ronald Guida [EMAIL PROTECTED] wrote:

 My present goal is to understand monads well enough to be able to
 explain them to others.  I wonder if it's possible to create a
 tutorial that explains monads well enough so that they just make
 sense or click for people.

It seems everyone wants to do this, with not much success! :-(

From reading this thread (piecemeal rather than in one concentrated
session) I get the impression that no-one agrees on what, if anything,
a monad is. If there were a wiki page What_Is_A_Monad and all these
ideas were whittled down whenever a counter-proof (such as Identity or
Reader) were raised --- what would be left?

I get the impression it would look like this:

  (return x) = f == f x
  m = return == m
  (m = f) = g == m = (\x - f x = g)

And then where would we be? ;-)

I say all this from the point of view of someone who has a reasonably
robust intuitive idea of monads that still fails to encompass the List
monad. I too would like to understand the overall idea to this monad
malarkey...

Cheers,

D.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


  1   2   >