[Haskell-cafe] Re: Editorial error or something meaningful?

2007-12-01 Thread Jon Fairbairn
PR Stanley [EMAIL PROTECTED] writes:

 Hi
 taken from ch.8.3 in the Hutton book:
 Whereas return v always succeeds, the dual parser failure
 always fails regardless of the contents of the input
 string:
 The dual parser failure?

It's a question of how you parse the phrase dual parser
failure.  The name of the parser is failure and it is the
dual (roughly meaning opposite) of the parser return.

-- 
Jón Fairbairn [EMAIL PROTECTED]


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


Re: [Haskell-cafe] Editorial error or something meaningful?

2007-12-01 Thread Daniel Fischer
Am Samstag, 1. Dezember 2007 07:18 schrieb PR Stanley:
 Hi
 taken from ch.8.3 in the Hutton book:
 Whereas return v always succeeds, the dual parser failure always
 fails regardless of the contents of the input string:
 The dual parser failure?
 Cheers,
 Paul

The dual parser, failure, probably.

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


Re: [Haskell-cafe] Re: Categories list in French (off-topic?)

2007-12-01 Thread david48
On Nov 30, 2007 9:13 PM, Maurí­cio [EMAIL PROTECTED] wrote:

 Nice tip. Do you know of a free news server
 that allows read and post for that group?

http://groups.google.com/group/fr.sci.maths/topics?lnk=gschg
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] trouble building unix-2.2.0.0 on cygwin

2007-12-01 Thread Claus Reinke

hi,

with the large number of just chatting messages on 
haskell-cafe, it is all too easy to miss problem reports

here. you might have a better chance asking on more
specific lists, eg. for ghc use, or library issues

http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
http://www.haskell.org/mailman/listinfo/libraries


 0) All work being done on cygwin. Version 6.8.1 of ghc.


the standard build of ghc uses cygwin tools to build a
no-cygwin ghc. in particular, ghc is not linked with the
posix-emulation libraries of cygwin, nor does it use cygwin's
compiler or linker. so, unless you've made a non-standard 
cygwin-linked ghc, the unix package is unlikely to build 
with that ghc. 


do you really need the unix package? a lot of general
functionality is available in platform-independent haskell
libraries, and some of the unix-package functionality is
available in unix compatibility packages.


1) I ran runhaskell Setup.lhs configure and did a tail -f config.log
in order to follow the config process.

2) Next I did the build runhaskell Setup.lhs build but there were
many include files referenced in HsUnix.h that couldn't be found, e.g.
sys/times.h, sys/resources.h, sys/wait.h, 

   3) I went back through the file config.log and all of the so-called
missing include files had supposedly been found during the config process.

   4) Next I went to c:/cygwin/usr/include/sys and found all of the
so-called missing include files.

   I am trying to get my confidence level up with respect to the
config/build/install (and along with darcs and haddock) process up high so I
can make a significant contribution to the Haskell effort. please .. any
help will be appreciated.


it is quite possible to work with a no-cygwin ghc in
a cygwin environment. the environment supplies the
build tools that some haskell packages and tools
need for configuration and build, then the no-cygwin 
ghc produces a no-cygwin executable (which can

be run from cygwin, or as any other windows-only
program).

that is indeed the default setup for ghc development
on windows, so darcs, haddock, etc. should work in
it, apart from a few rough edges. helping to smooth
those edges, where things that should work don't
quite work on windows, would be a significant
contribution, imho.

ideally, all haskell tools should work on windows
entirely without non-windows tools, and while that 
is not likely in the near future, many of them already

do, and reducing unix-dependencies helps to make
haskell easier to use for windows users (just as 
avoiding windows-dependencies ensures that unix

users are not excluded!-).

claus


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


[Haskell-cafe] Sequencing Parsers: a Simple Example

2007-12-01 Thread PR Stanley

Hi
(=) :: Parser a - Parser b - Parser b
p = f = \inp -
  case p inp of
[] - []
[(v, out)] - parse (f v) out
based on a lot of guesswork, after the mess created by the OCR, I 
managed to get the above example to work syntactically but is it 
semantically correct?

Thanks, Paul

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


Re: [Haskell-cafe] Sequencing Parsers: a Simple Example

2007-12-01 Thread Shachaf Ben-Kiki
 Hi
 (=) :: Parser a - Parser b - Parser b
 p = f = \inp -
case p inp of
  [] - []
  [(v, out)] - parse (f v) out
 based on a lot of guesswork, after the mess created by the OCR, I
 managed to get the above example to work syntactically but is it
 semantically correct?
 Thanks, Paul

You probably want:

(=) :: Parser a - (a - Parser b) - Parser b
p = f = \inp - case parse p inp of
[] - []
[(v,out)] - parse (f v) out

Assuming that you're following Graham Hutton's book.

Note that this definition won't actually compile; you probably need a
Monad instance and a newtype to get this to work properly (see
http://www.cs.nott.ac.uk/~gmh/Parsing.lhs for a working version of the
same code).

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


Re: [Haskell-cafe] Sequencing Parsers: a Simple Example

2007-12-01 Thread PR Stanley



   PRS: (=) :: Parser a - Parser b - Parser b
 p = f = \inp -
case p inp of
  [] - []
  [(v, out)] - parse (f v) out

You probably want:

(=) :: Parser a - (a - Parser b) - Parser b
p = f = \inp - case parse p inp of
[] - []
[(v,out)] - parse (f v) out

Assuming that you're following Graham Hutton's book.

Note that this definition won't actually compile; you probably need a
Monad instance and a newtype to get this to work properly (see
http://www.cs.nott.ac.uk/~gmh/Parsing.lhs for a working version of the
same code).
PRS: That explains it then. [(v, out)] - parse (f v) out caused a 
type mismatch.
Cheers, Paul 


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


[Haskell-cafe] ANN: Teach Yourself Gtk2Hs in 21 Hours

2007-12-01 Thread Hans van Thiel
Hello All,

The Gtk2Hs basics tutorial, based on the Tony Gale and Ian Main GTK+2.0
tutorial, is now available for review and comment. The TOC:

   1. Introduction
   2. Getting Started
   3. Packing
 3.1 Packing Widgets
 3.2 Packing Demonstration Program
 3.3 Packing Using Tables
   4. Miscellaneous Widgets
 4.1 The Button Widget
 4.2 Adjustments, Scale and Range
 4.3 Labels
 4.4 Arrows and Tooltips
 4.5 Dialogs, Stock Items and Progress Bars
 4.6 Text Entries and Status Bars
 4.7 Spin Buttons
   5. Aggregated Widgets
 5.1 Calendar
 5.2 File Selection
 5.3 Font and Color Selection
 5.4 Notebook
   6  Supporting Widgets
 6.1 Scrolled Windows
 6.2 Event Boxes and Button Boxes
 6.3 The Layout Container
 6.4 Paned Windows and Aspect Frames
   7. Action Based Widgets
 7.1 Menus and Toolbars
 7.2 Popup Menus, Radio Actions and Toggle Actions

This covers about half of Gtk2Hs (guesstimate) but (hopefully) most of
what's needed for the run of the mill GUI. It's available or will be on

http://darcs.haskell.org/gtk2hs/docs/tutorial/Tutorial_Port/

http://j-van-thiel.speedlinq.nl/gtk2hs/index.html

Thanks to Alex Tarkovsky it's in XHTML and well structured for easy
maintenance and adaptation. I hope a Gtk2Hs basics tutorial will help to
popularize this large, powerful and sophisticated gui library for
Haskell. Needless to say, please don't hesitate to comment and report
errors. 

Regards,

Hans van Thiel

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


Re: [Haskell-cafe] Illegal type def

2007-12-01 Thread Philip Weaver
Should work with glasgow extensions (-fglasgow-exts).

- Phil

On Dec 1, 2007 6:43 PM, PR Stanley [EMAIL PROTECTED] wrote:

 Hi
   type assoc k v = [(k, v)]

 works beautifully and everything makes sense.

   type Assoc v = (Ord k) = [(k, v)]

 This doesn't work. Is there any wayof defining k as an element of
 type Ordinal. I could redefine k by putting Char or Int in its place.
 Why can't I be more general?
 Thanks,
 Paul

 ___
 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] Illegal type def

2007-12-01 Thread Brandon S. Allbery KF8NH


On Dec 1, 2007, at 21:43 , PR Stanley wrote:


Hi
 type assoc k v = [(k, v)]

works beautifully and everything makes sense.

 type Assoc v = (Ord k) = [(k, v)]

This doesn't work. Is there any wayof defining k as an element of  
type Ordinal. I could redefine k by putting Char or Int in its  
place. Why can't I be more general?


Think of a type declaration as a macro which is expanded where it is  
used.  With parentheses around it and any unresolved references  
foralled, because it has no idea what to do with them at  
declaration time.


So, if you use -fglasgow-exts, you could make the above type  
declaration.  But when you use it:


  foo :: Assoc Int - Assoc Int

translates as

  foo :: (forall k. (Ord k) = [(k,Int)]) - (forall k. (Ord k) =  
[(k,Int)])


This is almost certainly *not* what you want; the two ks are  
independent.


It could be argued that GHC should be smarter about it... but  
formalizing what that means is difficult (and subject to disagreements).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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


[Haskell-cafe] Modelling a mutable variable store

2007-12-01 Thread Kannan Goundan

I'm implementing an interpreter for the lambda calculus augmented with 
mutable variables.  I'm having problems doing the mutable state stuff in 
Haskell.  Here's what I have so far:

  type Expr= ... terms in the language ...
  type Value   = ... values in the language ...
  type Ident   = String
  type VarId   = String

  type Env = Map Ident Target
  data Target = TValue Value | TVar VarId
-- idents might refer to values or vars in the store.

  type Store = Map VarId (Maybe Value)
-- Using Maybe because vars start out uninitialized.

  eval :: (Env, Store, Expr) - (Store, Value)
-- The Store is threaded through the evaluator.

One problem is that the link between an identifier and it's entry in the 
store is via VarIds, which are just strings.  For example, if I see the 
identifier x, I first look it up in the Env, and if it is a TVar, I 
then look it up in the store.  I'd like to get something stronger (in 
Java, I would use a pointer).  

Another problem is that entries in my Store never get garbage collected.  
Again, if I were using pointers in Java, this wouldn't be an issue.

There's also the issue of finding a more elegant way of threading the 
Store through my evaluator, but I'm not concerned too much about that at 
this point.  I can probably define a state-carrying monad like Parsec.  
My real concerns are the first two issues.

Thanks.

- Kannan

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


Re: [Haskell-cafe] Modelling a mutable variable store

2007-12-01 Thread Derek Elkins
On Sun, 2007-12-02 at 03:29 +, Robin Green wrote:
 On Sat, 01 Dec 2007 21:22:53 -0600
 Derek Elkins [EMAIL PROTECTED] wrote:
 
   There's also the issue of finding a more elegant way of threading
   the Store through my evaluator, but I'm not concerned too much
   about that at this point.  I can probably define a state-carrying
   monad like Parsec. My real concerns are the first two issues.
  
  Use ST.  First-class state isn't too great unless you specifically
  want that.
 
 Or use IO - that way you can use a Hashtable for looking up
 identifiers. Although, better still is to convert variable
 references into Ints, instead of using a Hashtable.

From what I hear, Data.HashTable is impressively inefficient to the
extent that you're better off using Data.Map solely for performance (not
to mention it being pure.)

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


[Haskell-cafe] Re: Modelling a mutable variable store

2007-12-01 Thread Kannan Goundan
On Sat, 01 Dec 2007 21:22:53 -0600, Derek Elkins wrote:

 Use ST.  First-class state isn't too great unless you specifically want
 that.

I did try using ST but ran into a problem because its type variable (s) 
ended up invading all of my types.

  -- Target needs 's' because of the STRef
  data Target s = TValue Value
| TVar (STRef s (Maybe Value))

  -- Env needs 's' because Target needs 's'
  type Env s = Map Ident (Target s)
  
  -- Value needs 's' because closures are values and closures
  -- have an Env.
  data Value s = VUnit
   | VClosure (Env s) Ident Expr

The main thing I didn't like was that 'Value' had a type parameter.  I 
didn't follow the ST option much past this point.  But maybe there's a 
better way to use ST?  Will existential types help me?

- Kannan

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


Re: [Haskell-cafe] Re: Modelling a mutable variable store

2007-12-01 Thread Stefan O'Rear
On Sun, Dec 02, 2007 at 03:54:05AM +, Kannan Goundan wrote:
 On Sat, 01 Dec 2007 21:22:53 -0600, Derek Elkins wrote:
 
  Use ST.  First-class state isn't too great unless you specifically want
  that.
 
 I did try using ST but ran into a problem because its type variable (s) 
 ended up invading all of my types.

That's just ST ugliness, the price you have to pay for a pure runST.  If
you're doing almost everything in ST, it can be cleaner just to use
IORefs.

Stefan


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


Re: [Haskell-cafe] Haskell interface file (.hi) format?

2007-12-01 Thread Tomasz Zielonka
On Fri, Nov 30, 2007 at 08:55:51AM +, Neil Mitchell wrote:
 Hi
 
Prelude :b Control.Concurrent.MVar
module 'Control.Concurrent.MVar' is not interpreted
 
 :b now defaults to :breakpoint, you want :browse

That's a questionable decision, IMO:
- it changes behavior
- I expect :browse to be used more often, so it deserves the sort
  :b version (:bro is not that short)

On the other hand, this change can have an (unintended?) feature
advertising effect ;-)

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


Re: [Haskell-cafe] Haskell interface file (.hi) format?

2007-12-01 Thread Stefan O'Rear
On Sun, Dec 02, 2007 at 05:45:48AM +0100, Tomasz Zielonka wrote:
 On Fri, Nov 30, 2007 at 08:55:51AM +, Neil Mitchell wrote:
  Hi
  
 Prelude :b Control.Concurrent.MVar
 module 'Control.Concurrent.MVar' is not interpreted
  
  :b now defaults to :breakpoint, you want :browse
 
 That's a questionable decision, IMO:
 - it changes behavior
 - I expect :browse to be used more often, so it deserves the sort
   :b version (:bro is not that short)
 
 On the other hand, this change can have an (unintended?) feature
 advertising effect ;-)

It's not a decision at all.  :b is the first command starting with b,
which was browse yesterday, is breakpoint today, and tomorrow will be
something you've never heard of.  It's inherently fragile, and shouldn't
be relied on in scripts - and if :b does anything funny, spell out the
command!

(There is a case to be made for explicitly defining short forms of
commands - but that is not what :b is, and making this case should only
be done in a new thread.)

Stefan


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


Re: [Haskell-cafe] Haskell interface file (.hi) format?

2007-12-01 Thread Tomasz Zielonka
On Sat, Dec 01, 2007 at 10:01:13PM -0800, Stefan O'Rear wrote:
 On Sun, Dec 02, 2007 at 05:45:48AM +0100, Tomasz Zielonka wrote:
  That's a questionable decision, IMO:
  - it changes behavior
  - I expect :browse to be used more often, so it deserves the sort
:b version (:bro is not that short)
  
  On the other hand, this change can have an (unintended?) feature
  advertising effect ;-)
 
 It's not a decision at all.  :b is the first command starting with b,
 which was browse yesterday, is breakpoint today, and tomorrow will be
 something you've never heard of.

I haven't thought about it this way. OK, so _this_ is the questionable
decision: allowing the ambiguous shortcut.

 It's inherently fragile, and shouldn't be relied on in scripts

I am only relying on it in my brain's procedural memory and I guess it's
going to fix itself eventually ;-)

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