Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-19 Thread Ketil Malde
michael rice  writes:

> Perhaps. Is there a Linux distro that's more XMonad friendly?

I use Ubuntu, in the GDM login screen, I get a drop down menu that
includes Xmonad as an option.  Even if Fedora doesn't have this, it
probably has a "Failsafe" option that will just give you an xterm, from
which you can run xmonad manually?

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Fwd: [BostonHaskell] Next meeting: January 21st at MIT (**NEW ROOM** 32G-449)

2010-01-19 Thread Ravi Nanavati
-- Forwarded message --
From: Ravi Nanavati 
Date: Wed, Jan 20, 2010 at 12:13 AM
Subject: Next meeting: January 21st at MIT (**NEW ROOM** 32G-449)
To: bostonhask...@googlegroups.com


I'm pleased to announce the January meeting of the Boston Area Haskell
Users' Group.

The meeting has been scheduled for Thursday, January 21st from 7pm to
9pm. Like recent meetings, it will be at MIT. However, it will be in
the Patil/Kiva conference room, NOT the CSAIL reading room. That room
is 32G-449 (i.e. a room on the 4th floor of the Gates Tower of MIT's
Stata Center at 32 Vassar St in Cambridge, MA). My apologies for the
late notice - I've been busy recently.

This month, Paul Chiusano and Runar Bjarnason will be presenting
"Scala for Haskell Programmers". Scala is a statically-typed
functional language that targets the JVM and it has a type system
that, in its own way, is as unique as Haskell's. This presentation
will take up the bulk of the meeting, but if anyone wants to give a
Lightning Talk, there is room for that.

The January attendance poll is at: http://doodle.com/xnwcec4w4hbh6y65

As always, responding to this poll will help with two things:
1. Getting an idea of what fraction of the Boston-area Haskell
community can and can't attend this meeting (to help with future
scheduling).
2. Giving me an estimated count of attendees, since I have talked my
wife into baking some more goodies and bringing drinks again.

By the way, if someone is willing to edit the HaskellWiki page, post
to reddit or otherwise publicize the meeting please just go ahead and
do that (especially as I'm sending this out on the later side).

If you have any questions about the meeting please send them to them
BostonHaskell mailing list: bostonhask...@googlegroups.com or contact
me directly.

I look forward to seeing many Boston-area Haskellers at the January meeting!

Thank you,

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


Re: [Haskell-cafe] Parsers (Parsec and Iteratee-based Parsers)

2010-01-19 Thread S. Doaitse Swierstra


On 12 jan 2010, at 00:09, Günther Schmidt wrote:


Hi John,

thanks for responding. As I said I've been using Parsec quite a lot,  
but wonder if there is a different approach possible/feasible to  
parsing. Parsec (2x) isn't an "online" parser, ie, it doesn't  
produce a result before the whole parse is completed.


There is AFAIK one alternative, the uulib, but at first glance it  
seemed very elaborate, so I wonder if Oleg's Iteratee offers  
something simpler.


There is the new uu-parsinglib package, which is simpler and  
documented (and being worked upon).


 Doaitse



I am not in particular looking for some sort of parsec-iteratee- 
hybrid, I'd be quite happy with something entirely based on  
Iteratee. In the Iteratee package there are 2 sample parsers, one  
for TIFF and one for WAVE files. I wish I could say that the  
accompanying documentation is sufficient for me to get the idea,  
alas it's not.


Günther

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


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


[Haskell-cafe] Re: Atom bug(?)

2010-01-19 Thread Lee Pike

Tom,

Ah, right.


The top-most rule is implied with the compile command.  This makes it
appear as if the assignment doesn't belong to a rule, when if fact it
belongs to the implicit top level rule.  The top level rule always has
a period of 1.

Period constraints are only applied to sub-rules, not the current
rule.


So to get the behavior I was expecting, I can name everything  
explicitly.  Then the assignment will inherit the period:



example :: Atom ()
-- example = period 3 $ do
example = period 3 $ atom "ex" $ do

 a <- word32 "a" 0

 a <== 21


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


[Haskell-cafe] Re: Atom bug(?)

2010-01-19 Thread Tom Hawkins
On Tue, Jan 19, 2010 at 10:42 PM, Lee Pike  wrote:
> Tom,
>
> Is this a bug?  The following program compiles, but the rule is scheduled at
> period 1 (rather than 0).  I wouldn't have thought to have an assignment
> outside of an atom until another engineer here wrote it.  In any event, I
> would have expected that the rule should have period 3.
>
> Lee
>
> example :: Atom ()
> example = period 3 $ do
>
>  a <- word32 "a" 0
>
>  a <== 21

The top-most rule is implied with the compile command.  This makes it
appear as if the assignment doesn't belong to a rule, when if fact it
belongs to the implicit top level rule.  The top level rule always has
a period of 1.

Period constraints are only applied to sub-rules, not the current
rule.  This prevents ambiguous situations, such as:

atom "something" $ do
  period 1 (a <== 1)  -- Does 'something' execute every 1 or ...
  period 2 (b <== 2)  -- 2 cycles?

So in your example, 'period 3' has no sub rules that it applies to.

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


Re: [Haskell-cafe] Parsers for Text Adventures; in one line

2010-01-19 Thread S. Doaitse Swierstra

When cycling home I realised it could even be shorter:

module Parse where

import Text.ParserCombinators.UU.Parsing
import Text.ParserCombinators.UU.Examples

data Verb = Go | Get | Jump | Climb | Give deriving (Show)

pCommand :: Pars Verb
pCommand = foldr (\ c r -> c <$ pToken (show c) <|> r)  pFail [Go ,  
Get , Jump , Climb , Give]



*Parse> test pCommand "Go"
Loading package syb ... linking ... done.
Loading package base-3.0.3.1 ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package filepath-1.1.0.2 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.2 ... linking ... done.
Loading package unix-2.3.2.0 ... linking ... done.
Loading package directory-1.0.0.3 ... linking ... done.
Loading package process-1.0.1.1 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package uu-parsinglib-2.3.1 ... linking ... done.
(Go,[])
se> *Parse> test pCommand "Clim"
(Climb,[
Inserted 'b' at position 4 expecting 'b'])
*Parse>



On 19 jan 2010, at 17:31, S.Doaitse Swierstra wrote:

How about using one of the existing libraries, in this case uu- 
parsinglib:


module Parse where

import Text.ParserCombinators.UU.Parsing
import Text.ParserCombinators.UU.Examples

data Verb = Go | Get | Jump | Climb | Give deriving (Show)

pCommand :: Pars String
pCommand = foldr (<|>) pFail (map str2com [(Go, "Go"), (Get, "Get"),  
(Jump, "Jump"), (Give, "Climb"), (Climb, "Give")])


str2com (comm, str) = show comm <$ pToken str


and then (the show is for demonstration purposes only; not the swap  
in the last two elements in the list)


*Parse> :load "../Test.hs"
[1 of 1] Compiling Parse( ../Test.hs, interpreted )
Ok, modules loaded: Parse.
*Parse> test pCommand "Go"
("Go",[])
*Parse> test pCommand "G0"
("Go",[
Deleted  '0' at position 1 expecting 'o',
Inserted 'o' at position 2 expecting 'o'])
*Parse> test pCommand "o"
("Go",[
Inserted 'G' at position 0 expecting one of ['G', 'G', 'J', 'C',  
'G']])

*Parse> test pCommand "Clim"
("Give",[
Inserted 'b' at position 4 expecting 'b'])
*Parse>


On 17 jan 2010, at 14:30, Mark Spezzano wrote:


Hi,

I am writing a Text Adventure game in Haskell (like Zork)

I have all of the basic parser stuff written as described in  
Hutton's Programming in Haskell and his associated papers. (I'm  
trying to avoid using 3rd party libraries, so that I can learn this  
myself)


Everything that I have works (so far...) except for the following  
problem:


I want to define a grammar using a series of Verbs like this:

data Verb = Go | Get | Jump | Climb | Give etc, etc deriving (Show,  
Read)


and then have my parser "get" one of these Verb tokens if possible;  
otherwise it should do something (?) else like give an error  
message stating "I don't know that command"


Now, Hutton gives examples of parsing strings into string whereas I  
want to parse Strings into my Verbs


So, if the user types "get sword" then it will tokenise "get" as  
type Verb's data constructor Get and perhaps "sword" into a Noun  
called Sword


My parser is defined like this:

newtype Parser a = Parser (String -> [(a, String)])

So I CAN give it a Verb type

but this is where I run into a problem

I've written a Parser called keyword

keyword :: Parser Verb
keyword = do x <- many1 letter
return (read x)

(read this as "take-at-least-one-alphabetic-letter-and-convert-to-a- 
Verb-type")


which DOES work provided that the user types in one of my Verbs. If  
they don't, well, the whole thing fails with an Exception and halts  
processing, returning to GHCi prompt.


Question: Am I going about this the right way? I want to put  
together lots of "data" types like Verb and Noun etc so that I can  
build a kind of "BNF grammar".


Question: If I am going about this the right way then what do I  
about the "read x" bit failing when the user stops typing in a  
recognised keyword. I could catch the exception, but typing an  
incorrect sentence is just a typo, not really appropriate for an  
exception, I shouldn't think. If it IS appropriate to do this in  
Haskell, then how do I catch this exception and continue processing.


I thought that exceptions should be for exceptional circumstances,  
and it would seem that I might be misusing them in this context.


Thanks

Mark Spezzano

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


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


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell

[Haskell-cafe] Non-ASCII characters in .cabal files break Haddock?

2010-01-19 Thread John Millikin
I recently uploaded a package to Hackage[1], which contains a
non-ASCII character in the .cabal file. That file is encoded with
UTF-8, and it displays fine in Vim, Firefox, and even the Hackage
package landing page. However, Haddock is failing to build it[2] --
apparently it can't handle UTF-8 encoded text properly.

In documentation sections, Haddock supports special syntax for
escaping non-ASCII. Is there any equivalent syntax for Cabal files?

[1] http://hackage.haskell.org/package/natural-sort'
[2] 
http://hackage.haskell.org/packages/archive/natural-sort/0.1/logs/failure/ghc-6.12
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Functional Programming Bibliography

2010-01-19 Thread Henning Thielemann
James Russell schrieb:

> 
> Not much to it, really.  It's a LAMH thing, if you will.
> 
> The Haskell part just runs as a CGI app,
> and uses the HDBC, HDBC-mysql, cgi, and xhtml
> packages, and is just a few hundred lines, including all
> the html templates which I create with the xhtml package.
> 
> As for the bibliography stuff,
> right now I actually maintain a master .bib file
> and use bibTeX along with a set of custom .bst files
> to munge everything up to be imported into MySQL.

Interesting. Some time ago I managed a preprints list using a self-made
Haskell program, where all entries where stored in a BibTeX file.
  http://www.math.uni-bremen.de/zetem/DFG-Schwerpunkt/preprints/

Recently I have extracted its BibTeX parsing and generating to:
  http://hackage.haskell.org/package/bibtex
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] cabal install glfw

2010-01-19 Thread Paul L
The problem you mentioned has long been fixed in the darcs version,
but then there is also another problem: you need GHC 6.12 in order to
compile GLFW for Snow Leopard. Here is a detail description of why
prior versions of GHC fails to work:
http://hackage.haskell.org/trac/ghc/ticket/3522

I've just made a new release and bumped GLFW to 0.4.2, you may try it
with GHC 6.12 on Snow Leopard and see if it now works.


On 1/19/10, Ozgur Akgun  wrote:
> Dear Cafe and Paul,
>
> I am constantly having problems with cabal install in Snow Leopard. Some I
> solve, some I cannot unfortunately.
>
> When I run
>
> sudo cabal install glfw -v2
>
> in Snow Leopard, I get the following.
>
> glfw/lib/macosx/macosx_enable.c:1:0:
>  error: bad value (apple) for -march= switch
>
> glfw/lib/macosx/macosx_enable.c:1:0:
>  error: bad value (apple) for -mtune= switch
> cabal: Error: some packages failed to install:
> GLFW-0.4.1 failed during the building phase. The exception was:
> exit: ExitFailure 1
>
>
> Regards,
>
> --
> Ozgur Akgun
>


-- 
Regards,
Paul Liu

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


Re[4]: [Haskell-cafe] Poor man's generic programming

2010-01-19 Thread Bulat Ziganshin
Hello Neil,

Tuesday, January 19, 2010, 10:15:15 PM, you wrote:

>> can you give a permission to translate 
>> http://community.haskell.org/~ndm/darcs/uniplate/uniplate.htm
>> to Russian for http://fprog.ru/ online functional programming journal?

> Yes, that sounds great. However, I'm currently not a particular fan of
> the manual in it's current state - it isn't that well written and some
> bits need expanding. How about I revamp it, then let you know? I can
> probably do it within the next few weeks.

it would be even better. i just finished reading your paper - tutorial
doesn't emphasize some details i've found there, in particular
restrictions of Uniplate and how these are particularly overcomed by
BiPlate. i.e. it may be derived from tutorial but wasn't obvious for
me before i've read the paper


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


[Haskell-cafe] Re: Darcs fundraising 2010 - send us to ZuriHac! (only $1333 more by 15 Feb)

2010-01-19 Thread Eric Y. Kow
Hi everybody,

I'm just writing to thank everybody for your donations so far to the
Darcs 2010 travel fund, and to give a little progress update.

Thanks to your generous contributions, we've managed to raise $667,
putting us 1/3 of the way there!  We only have $1333 to go, that's a
little over three hundred to meet last year's target and a thousand more
to make our 2010 objectives.

If you're still thinking of helping out, now is a good time! :-)
Otherwise, stay tuned at http://darcs.net/donations.html for our
progress.

Eric

PS. If you could send me an email when you make a donation, I can
provide a daily update on our fundraising status.

Donating by Google Checkout
--
Donating via Google Checkout puts more of your donation to work, since
Google charges no Checkout fees to 501(c)(3) organizations.

Please visit http://darcs.net/donations.html for more details.

Donating by check (USA)
--
The next best option is to donate by check if you have a US bank
account.  Checks should be made payable to "Software Freedom
Conservancy, Inc.", with "Directed donation: Darcs" in the memo. They
can be mailed to

Software Freedom Conservancy
1995 BROADWAY FL 17
NEW YORK NY 10023-5882 USA

Donating by Paypal
--
Please visit http://darcs.net/donations.html for more details.

-- 
Eric Kow 
PGP Key ID: 08AC04F9


pgpqQUmTfhsdW.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Poor man's generic programming

2010-01-19 Thread Neil Mitchell
Hi Bulat,

>> Uniplate might be the answer you are looking for -
>> http://community.haskell.org/~ndm/uniplate
>
> it's brilliant! some people has the talent to discover complex things
> and you have the talent to make complex things simple. it's first and only
> generics library that i can easily learn and remember

I'm very glad you like it :-)

> can you give a permission to translate 
> http://community.haskell.org/~ndm/darcs/uniplate/uniplate.htm
> to Russian for http://fprog.ru/ online functional programming journal?

Yes, that sounds great. However, I'm currently not a particular fan of
the manual in it's current state - it isn't that well written and some
bits need expanding. How about I revamp it, then let you know? I can
probably do it within the next few weeks.

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


Re: [Haskell-cafe] Poor man's generic programming

2010-01-19 Thread Neil Mitchell
Hi Henning,

>> Uniplate is simple (only multi parameter type classes, and even then
>> only in a very simple usage), fast (one of the fastest generics
>> libraries) and concise (probably the most concise generics library).
>> It's also not as powerful as most of the other generics libraries, but
>> I find it does about 98% of the generics tasks I need. Uniplate is
>> used extensively in virtually all my tools, for example HLint.
>>
>
> Must a package import Uniplate, if it uses Uniplate generics, or is it a
> preprocessor like I sketched?

Uniplate is a library, not a preprocessor. To depend on uniplate
simply add it to your cabal file, and import the correct module. There
is no preprocessor, and there are no wacky extensions. If you restrict
yourself to some part of the library it's even totally Haskell 98, but
none of it's not Haskell 2011.

>> As an example, I guess your function returns all the Int's embedded
>> within a data type, at any level?
>
> I abstracted the Bin example from GHC's generic extension introduction:

That's one thing Uniplate can't do. But if you want a preprocessor to
generate Binary instances can I recommend Derive
(http://community.haskell.org/~ndm/derive).

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


[Haskell-cafe] cabal install glfw

2010-01-19 Thread Ozgur Akgun
Dear Cafe and Paul,

I am constantly having problems with cabal install in Snow Leopard. Some I
solve, some I cannot unfortunately.

When I run

sudo cabal install glfw -v2

in Snow Leopard, I get the following.

glfw/lib/macosx/macosx_enable.c:1:0:
 error: bad value (apple) for -march= switch

glfw/lib/macosx/macosx_enable.c:1:0:
 error: bad value (apple) for -mtune= switch
cabal: Error: some packages failed to install:
GLFW-0.4.1 failed during the building phase. The exception was:
exit: ExitFailure 1


Regards,

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


Re: [Haskell-cafe] #haskell stopped being logged on tunes.org

2010-01-19 Thread Ivan Lazar Miljenovic
Eugene Kirpichov  writes:
> I am not even sure whether this should be fixed on the tunes.org site
> or on #haskell's, but something has to be done,

How about getting everyone to register and be identified? *ducks*

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsers for Text Adventures; small typo corrected in example

2010-01-19 Thread Peter Verswyvelen
The original author said he did not want to use existing parser
libraries, but write it himself for learning. After I read
"introduction to functional programming" from Bird, I closed the book,
and re-wrote the parser from scratch again, and seeing how all these
pieces come together was such a wonderful experience that I would
recommend everyone to this once instead of immediately using an
existing library :-)

It seems Marks parser definition lacks error information. It's been a
while since I played with Haskell, but if I recall correctly, you
could define a parser with backtracking that carries errors as:

type Error = String
newtype Parser a = Parser (String -> Either Error [(a, String)])

or was it
newtype Parser a = Parser (String -> [(Either Error a, String)])

in any case, when combining parsers using >>=, the errors must be propagated.

As you can see, I forgot the correct solution myself, so now I would
indeed use a library, since I know I could do it once ;)


On Tue, Jan 19, 2010 at 5:31 PM, S.Doaitse Swierstra
 wrote:
> How about using one of the existing libraries, in this case uu-parsinglib:
>
> module Parse where
>
> import Text.ParserCombinators.UU.Parsing
> import Text.ParserCombinators.UU.Examples
>
> data Verb = Go | Get | Jump | Climb | Give deriving (Show)
>
> pCommand :: Pars String
> pCommand = foldr (<|>) pFail (map str2com [(Go, "Go"), (Get, "Get"), (Jump,
> "Jump"), (Give, "Climb"), (Climb, "Give")])
>
> str2com (comm, str) = show comm <$ pToken str
>
>
> and then (the show is for demonstration purposes only; not the swap in the
> last two elements in the list)
>
> *Parse> :load "../Test.hs"
> [1 of 1] Compiling Parse            ( ../Test.hs, interpreted )
> Ok, modules loaded: Parse.
> *Parse> test pCommand "Go"
> ("Go",[])
> *Parse> test pCommand "G0"
> ("Go",[
> Deleted  '0' at position 1 expecting 'o',
> Inserted 'o' at position 2 expecting 'o'])
> *Parse> test pCommand "o"
> ("Go",[
> Inserted 'G' at position 0 expecting one of ['G', 'G', 'J', 'C', 'G']])
> *Parse> test pCommand "Clim"
> ("Give",[
> Inserted 'b' at position 4 expecting 'b'])
> *Parse>
>
>
> On 17 jan 2010, at 14:30, Mark Spezzano wrote:
>
>> Hi,
>>
>> I am writing a Text Adventure game in Haskell (like Zork)
>>
>> I have all of the basic parser stuff written as described in Hutton's
>> Programming in Haskell and his associated papers. (I'm trying to avoid using
>> 3rd party libraries, so that I can learn this myself)
>>
>> Everything that I have works (so far...) except for the following problem:
>>
>> I want to define a grammar using a series of Verbs like this:
>>
>> data Verb = Go | Get | Jump | Climb | Give etc, etc deriving (Show, Read)
>>
>> and then have my parser "get" one of these Verb tokens if possible;
>> otherwise it should do something (?) else like give an error message stating
>> "I don't know that command"
>>
>> Now, Hutton gives examples of parsing strings into string whereas I want
>> to parse Strings into my Verbs
>>
>> So, if the user types "get sword" then it will tokenise "get" as type
>> Verb's data constructor Get and perhaps "sword" into a Noun called Sword
>>
>> My parser is defined like this:
>>
>> newtype Parser a = Parser (String -> [(a, String)])
>>
>> So I CAN give it a Verb type
>>
>> but this is where I run into a problem
>>
>> I've written a Parser called keyword
>>
>> keyword :: Parser Verb
>> keyword = do x <- many1 letter
>>                        return (read x)
>>
>> (read this as
>> "take-at-least-one-alphabetic-letter-and-convert-to-a-Verb-type")
>>
>> which DOES work provided that the user types in one of my Verbs. If they
>> don't, well, the whole thing fails with an Exception and halts processing,
>> returning to GHCi prompt.
>>
>> Question: Am I going about this the right way? I want to put together lots
>> of "data" types like Verb and Noun etc so that I can build a kind of "BNF
>> grammar".
>>
>> Question: If I am going about this the right way then what do I about the
>> "read x" bit failing when the user stops typing in a recognised keyword. I
>> could catch the exception, but typing an incorrect sentence is just a typo,
>> not really appropriate for an exception, I shouldn't think. If it IS
>> appropriate to do this in Haskell, then how do I catch this exception and
>> continue processing.
>>
>> I thought that exceptions should be for exceptional circumstances, and it
>> would seem that I might be misusing them in this context.
>>
>> Thanks
>>
>> Mark Spezzano
>>
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_

[Haskell-cafe] #haskell stopped being logged on tunes.org

2010-01-19 Thread Eugene Kirpichov
Hello.

The #haskell channel stopped being logged because now it accepts only
someone who has IDENTIFY'd. For the last 3 days essentially nothing
has been recorded.
I am not even sure whether this should be fixed on the tunes.org site
or on #haskell's, but something has to be done, and I plea those with
sufficient power for that to do it :)

-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Parsers for Text Adventures; small typo corrected in example

2010-01-19 Thread S . Doaitse Swierstra
How about using one of the existing libraries, in this case uu- 
parsinglib:


module Parse where

import Text.ParserCombinators.UU.Parsing
import Text.ParserCombinators.UU.Examples

data Verb = Go | Get | Jump | Climb | Give deriving (Show)

pCommand :: Pars String
pCommand = foldr (<|>) pFail (map str2com [(Go, "Go"), (Get, "Get"),  
(Jump, "Jump"), (Give, "Climb"), (Climb, "Give")])


str2com (comm, str) = show comm <$ pToken str


and then (the show is for demonstration purposes only; not the swap in  
the last two elements in the list)


*Parse> :load "../Test.hs"
[1 of 1] Compiling Parse( ../Test.hs, interpreted )
Ok, modules loaded: Parse.
*Parse> test pCommand "Go"
("Go",[])
*Parse> test pCommand "G0"
("Go",[
Deleted  '0' at position 1 expecting 'o',
Inserted 'o' at position 2 expecting 'o'])
*Parse> test pCommand "o"
("Go",[
Inserted 'G' at position 0 expecting one of ['G', 'G', 'J', 'C', 'G']])
*Parse> test pCommand "Clim"
("Give",[
Inserted 'b' at position 4 expecting 'b'])
*Parse>


On 17 jan 2010, at 14:30, Mark Spezzano wrote:


Hi,

I am writing a Text Adventure game in Haskell (like Zork)

I have all of the basic parser stuff written as described in  
Hutton's Programming in Haskell and his associated papers. (I'm  
trying to avoid using 3rd party libraries, so that I can learn this  
myself)


Everything that I have works (so far...) except for the following  
problem:


I want to define a grammar using a series of Verbs like this:

data Verb = Go | Get | Jump | Climb | Give etc, etc deriving (Show,  
Read)


and then have my parser "get" one of these Verb tokens if possible;  
otherwise it should do something (?) else like give an error message  
stating "I don't know that command"


Now, Hutton gives examples of parsing strings into string whereas I  
want to parse Strings into my Verbs


So, if the user types "get sword" then it will tokenise "get" as  
type Verb's data constructor Get and perhaps "sword" into a Noun  
called Sword


My parser is defined like this:

newtype Parser a = Parser (String -> [(a, String)])

So I CAN give it a Verb type

but this is where I run into a problem

I've written a Parser called keyword

keyword :: Parser Verb
keyword = do x <- many1 letter
return (read x)

(read this as "take-at-least-one-alphabetic-letter-and-convert-to-a- 
Verb-type")


which DOES work provided that the user types in one of my Verbs. If  
they don't, well, the whole thing fails with an Exception and halts  
processing, returning to GHCi prompt.


Question: Am I going about this the right way? I want to put  
together lots of "data" types like Verb and Noun etc so that I can  
build a kind of "BNF grammar".


Question: If I am going about this the right way then what do I  
about the "read x" bit failing when the user stops typing in a  
recognised keyword. I could catch the exception, but typing an  
incorrect sentence is just a typo, not really appropriate for an  
exception, I shouldn't think. If it IS appropriate to do this in  
Haskell, then how do I catch this exception and continue processing.


I thought that exceptions should be for exceptional circumstances,  
and it would seem that I might be misusing them in this context.


Thanks

Mark Spezzano

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


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


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-19 Thread michael rice
How did you configure it? Are you still using it?

Michael

--- On Tue, 1/19/10, Chaddaï Fouché  wrote:

From: Chaddaï Fouché 
Subject: Re: [Haskell-cafe] Having a look at XMonad window manager
To: "John Millikin" 
Cc: "michael rice" , haskell-cafe@haskell.org
Date: Tuesday, January 19, 2010, 10:18 AM

On Mon, Jan 18, 2010 at 11:53 PM, John Millikin  wrote:
> I've been quite happy with Ubuntu's xmonad package, though I run it
> within a GNOME session.
>
> Have you tried the instructions on the XMonad wiki for inter-operating
> with GNOME? http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome

I myself had such a setup (Xmonad in Gnome on Ubuntu) for more than a
year and it really was quite good. XMonad works quite well with
KDE/Gnome or other major desktops.

-- 
Jedaï



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


Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-19 Thread Chaddaï Fouché
On Mon, Jan 18, 2010 at 11:53 PM, John Millikin  wrote:
> I've been quite happy with Ubuntu's xmonad package, though I run it
> within a GNOME session.
>
> Have you tried the instructions on the XMonad wiki for inter-operating
> with GNOME? http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_in_Gnome

I myself had such a setup (Xmonad in Gnome on Ubuntu) for more than a
year and it really was quite good. XMonad works quite well with
KDE/Gnome or other major desktops.

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


Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-19 Thread S. Doaitse Swierstra
How about using one of the existing libraries, in this case uu- 
parsinglib:


module Parse where

import Text.ParserCombinators.UU.Parsing
import Text.ParserCombinators.UU.Examples

data Verb = Go | Get | Jump | Climb | Give deriving (Show)

pCommand :: Pars String
pCommand = foldr (<|>) pFail (map str2com [(Go, "G0"), (Get, "Get"),  
(Jump, "Jump"), (Give, "Climb"), (Climb, "Give")])


str2com (comm, str) = show comm <$ pToken str


and then (the show is for demonstration purposes only; not the swap in  
the last two elements in the list)


*Parse> :load "../Test.hs"
[1 of 1] Compiling Parse( ../Test.hs, interpreted )
Ok, modules loaded: Parse.
*Parse> test pCommand "Go"
("Go",[])
*Parse> test pCommand "G0"
("Go",[
Deleted  '0' at position 1 expecting 'o',
Inserted 'o' at position 2 expecting 'o'])
*Parse> test pCommand "o"
("Go",[
Inserted 'G' at position 0 expecting one of ['G', 'G', 'J', 'C', 'G']])
*Parse> test pCommand "Clim"
("Give",[
Inserted 'b' at position 4 expecting 'b'])
*Parse>


On 17 jan 2010, at 14:30, Mark Spezzano wrote:


Hi,

I am writing a Text Adventure game in Haskell (like Zork)

I have all of the basic parser stuff written as described in  
Hutton's Programming in Haskell and his associated papers. (I'm  
trying to avoid using 3rd party libraries, so that I can learn this  
myself)


Everything that I have works (so far...) except for the following  
problem:


I want to define a grammar using a series of Verbs like this:

data Verb = Go | Get | Jump | Climb | Give etc, etc deriving (Show,  
Read)


and then have my parser "get" one of these Verb tokens if possible;  
otherwise it should do something (?) else like give an error message  
stating "I don't know that command"


Now, Hutton gives examples of parsing strings into string whereas I  
want to parse Strings into my Verbs


So, if the user types "get sword" then it will tokenise "get" as  
type Verb's data constructor Get and perhaps "sword" into a Noun  
called Sword


My parser is defined like this:

newtype Parser a = Parser (String -> [(a, String)])

So I CAN give it a Verb type

but this is where I run into a problem

I've written a Parser called keyword

keyword :: Parser Verb
keyword = do x <- many1 letter
return (read x)

(read this as "take-at-least-one-alphabetic-letter-and-convert-to-a- 
Verb-type")


which DOES work provided that the user types in one of my Verbs. If  
they don't, well, the whole thing fails with an Exception and halts  
processing, returning to GHCi prompt.


Question: Am I going about this the right way? I want to put  
together lots of "data" types like Verb and Noun etc so that I can  
build a kind of "BNF grammar".


Question: If I am going about this the right way then what do I  
about the "read x" bit failing when the user stops typing in a  
recognised keyword. I could catch the exception, but typing an  
incorrect sentence is just a typo, not really appropriate for an  
exception, I shouldn't think. If it IS appropriate to do this in  
Haskell, then how do I catch this exception and continue processing.


I thought that exceptions should be for exceptional circumstances,  
and it would seem that I might be misusing them in this context.


Thanks

Mark Spezzano

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


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


[Haskell-cafe] ZuriHac registration deadline on February 14, 2010

2010-01-19 Thread Johan Tibell
Hi all,

Due to budget and security constraints, we need to know the final
number of attendees a bit in advance. We've therefore set a
registration deadline on February 14, 2010. To register please follow
the instructions on the registration page:

http://www.haskell.org/haskellwiki/ZuriHac/Register

Cheers,

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


[Haskell-cafe] Re: parallel matrix multiply (dph, par/pseq)

2010-01-19 Thread Johannes Waldmann

> ... use Array (Int,Int) Double, as it accesses its elements in O(1). 

thanks for the comments.

I don't need O(dim^0) element access - 
I need O(dim^reasonable) addition and multiplication.

Modelling a matrix as [[Element]] should be nearly fine 
(for sequential execution), I think these are quadratic/cubic:

a * b = zipWith (zipWith (+)) a b  
a * b = for a $ \ row -> 
for ( transpose b ) $ \ col -> 
sum $ zipWith (*) row col

The only problem with this code is that 'transpose b'
(assuming the compiler lifts it to outer scope)
allocates memory that later becomes garbage,
but not immediately, since it is needed several times.

( in the above, for = flip map  , 
which is missing from the standard libs?
by analogy to  forM = flip mapM )

Best regards, J.W.

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


Re: [Haskell-cafe] Re: Declarative binary protocols

2010-01-19 Thread Martijn van Steenbergen

Antoine Latter wrote:

getResponse = do
  require 256
  x <- getX
  len <- getWord16be
  y <- getY
  z <- getZ
  require (fromIntegral len * 8)
  a <- getA
  b <- getB
  return $ Response x y z a b c


This looks like code that could be written in applicative style, in 
which case you could analyze the parser and automatically compute how 
many bytes are needed, removing the need for explicit calls to require.


Groetjes,

Martijn.

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


Re: [Haskell-cafe] sorting and merging in haskell

2010-01-19 Thread Eugene Kirpichov
Use the 'sortBy' and 'group' functions from Data.List. The rest is quite easy.
Or you might use a Data.Map (degree => coefficient), particularly the
fromListWith function.

2010/1/19 jjoshua :
>
> So I defined a type called term which is a coefficient and degree of x. int a
> int b.
> I want to write a method/methods in haskell to sort them and combine ones
> with same degree. I think I need to combine somehow, and then use sortby
> method? I'm just learning haskell, but I now java and c# pretty well and I'm
> having a hard term converting to functional thinking.
> its of type [(Int a Int b)] and if b1< b2 put tuple 1 before tuple2, else if
> = combine by adding a1 to a2, else place 2 before 1. I know how to do it
> logically, just not the syntax I guess.
> Thanks so much guys!
> --
> View this message in context: 
> http://old.nabble.com/sorting-and-merging-in-haskell-tp27222668p27222668.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] sorting and merging in haskell

2010-01-19 Thread jjoshua

So I defined a type called term which is a coefficient and degree of x. int a
int b.
I want to write a method/methods in haskell to sort them and combine ones
with same degree. I think I need to combine somehow, and then use sortby
method? I'm just learning haskell, but I now java and c# pretty well and I'm
having a hard term converting to functional thinking.
its of type [(Int a Int b)] and if b1< b2 put tuple 1 before tuple2, else if
= combine by adding a1 to a2, else place 2 before 1. I know how to do it
logically, just not the syntax I guess.
Thanks so much guys!
-- 
View this message in context: 
http://old.nabble.com/sorting-and-merging-in-haskell-tp27222668p27222668.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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