Re: -pgm option syntax

2002-02-20 Thread Jens Petersen

Jens Petersen [EMAIL PROTECTED] writes:

 Jens Petersen [EMAIL PROTECTED] writes:
 
  It would be good if ghc would at like give a better error
  message when an empty cmd is passed to -pgmX.
 
 Rather I think it should abort rather than forking an empty
 command...

How about something like the following untested patch to
this effect?  (In the ideal world it would test that c is a
valid program flag, but anyway...)

Jens


2002-02-20  Jens Petersen  [EMAIL PROTECTED]

* compiler/main/SysTools.lhs (setPgm): Abort when a null cmd is
passed to a -pgmX option.

Index: SysTools.lhs
===
RCS file: /cvs/fptools/ghc/compiler/main/SysTools.lhs,v
retrieving revision 1.70
diff -u -r1.70 SysTools.lhs
--- SysTools.lhs2002/02/16 19:39:51 1.70
+++ SysTools.lhs2002/02/20 13:15:44
@@ -417,6 +417,7 @@
 -- The string is the flag, minus the '-pgm' prefix
 -- So the first character says which program to override
 
+setPgm ([c]) = throwDyn (UsageError (-pgm ++ [c]: no CMD argument))
 setPgm ('P' : pgm) = writeIORef v_Pgm_P pgm
 setPgm ('F' : pgm) = writeIORef v_Pgm_F pgm
 setPgm ('c' : pgm) = writeIORef v_Pgm_c pgm
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Typing RULES

2002-02-20 Thread Josef Svenningsson

Hi!

Ghc seems to have some problems in inferring the most general types of
RULES pragmas. The bug was not present in 5.02.1 but shows up in a cvs
version checked out yesterday.

Here's the problem:
Consider the following example from the user's guide:

{-# RULES
 map/map forall f g xs. map f (map g xs) = map (f.g) xs
#-}

When I compile with -ddump-rules I get the following rule:

map/map __forall {@ b
@ b
@ a
f :: (b - b)
g :: (a - b)
xs :: [a]}
GHC.Base.map @ b @ b f (GHC.Base.map @ a @ b g xs)
= GHC.Base.map @ a @ b (GHC.Base.. @ b @ b @ a f g) xs ;

(And it also turns out this rule is listed among the imported rules, not
the local ones, which is a bit confusing.)

The rule says that f must have type b - b for some b. This is clearly Bad
as the matching algorithm also matches types and the rule will not be
fired in all the cases it should.

When I add a type signature for f then g get type b - b. In order to get
the desired behaviour I have to add type signatures to both f and g.

I hope this is easy to fix.

Cheers,

/Josef

PS. Would it be possible to add a -fwarn-pragma which warns when a pragma
is ignored? It is quite frustrating when some rules are silently ignored
and you keep wonder why the rules don't fire. I guess I've learnt to use
-ddump-rule the hard way...

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Re: Congrats to Mandrake

2002-02-20 Thread Ketil Z. Malde

Ashley Yakeley [EMAIL PROTECTED] writes:

 At 2002-02-19 14:13, Duncan Coutts wrote:
 
 So what I mean is, can we have links to more binaries than just Red Hat?
 Debian, Mandrake, FreeBSD. (I know these's SuSE)

 Seconded.

I'm not sure what the point would be, if they are in the
distributions anyway?  Isn't it better to install them by apt-get or
up2date or whatever?  (In fact, I had almost thought manually
downloading packages a thing of the past, but then the IT department
insisted on Red Hat)

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: Importing a reference to a non-function entity.

2002-02-20 Thread Simon Marlow

 What is the politically correct way using the FFI and ghc5.03 
 (which I have just managed to compile from
 CVS) to import an externally defined object (not a function)? 
  I have a source file containing the line
 
 foreign label default_options defaultOptions :: CString.CString
 
 for which ghc5.03 complains about Warning: foreign 
 declaration uses deprecated non-standard syntax,
 but which works anyway.  However in my attempt to be a good 
 little ghc user, I try instead
 
 foreign import default_options defaultOptions :: CString.CString
 
 (after deciphering with difficulty the Postscript version of 
 the FFI document on this screen) but
 still get the deprecated warning.  Then I try
 
 foreign import ccall default_options defaultOptions :: 
 CString.CString

I believe you meant to say 

  foreign import ccall default_options 
 defaultOptions :: CString.Cstring

:-)  (see the latest FFI addendum at http://www.cse.unsw.edu.au/~chak/haskell/ffi/)

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: Data constructors and pattern matching

2002-02-20 Thread Simon Marlow

 It seems to me that it might be very useful for a module to export the
 pattern matching operators for a datatype without exporting the
 constructors.  Suppose we have
 
 data A = X {a::Int, b::Float}
 
 And we want to maintain the invariant that b is a floating-point
 representation of a.  So normally we would have to use a completely
 abstract datatype, and provide constructors and destructors.  But in
 this case, it would actually make sense to provide the 
 pattern-matching
 operator X, but not the data constructor X.  So I think it 
 would be good
 to separate these in the module export syntax.

What's wrong with

module M (A, a, b) where { ... }

?

Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: Congrats to Mandrake

2002-02-20 Thread Simon Marlow


 Jim Farrand  [EMAIL PROTECTED] wrote:
   both hugs and ghc in their Linux distro *as standard*. This could
   significantly help Haskell takeup amongst the unwashed 
 masses. :-)
  Well, same applies for FreeBSD.
 
  And Debian.
 
 So what I mean is, can we have links to more binaries than 
 just Red Hat?
 Debian, Mandrake, FreeBSD. (I know these's SuSE)
 
 It may just seem like clutter on the download page but it 
 would help users and 
 as much as anything else it shows some apreciation for the 
 packagers who track 
 the releases so well.

Oops!  Looks like I added the FreeBSD packages to my local copy of the
web pages and forgot to copy it up to the web site.  Sorry about that.

I'll add links to the Mandrake packages while I'm there.

Could someone who is Debian-compliant tell me where I should be pointing
for Debian packages?

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Congrats to Mandrake

2002-02-20 Thread Albert Lai

[EMAIL PROTECTED] (Ketil Z. Malde) writes:

 I'm not sure what the point would be, if they are in the
 distributions anyway?  Isn't it better to install them by apt-get or
 up2date or whatever?  (In fact, I had almost thought manually
 downloading packages a thing of the past, but then the IT department
 insisted on Red Hat)

If I, a developer, wrote a program, and some distributions included it
(while others didn't), I would want to acknowledge and thank them in
public.

If I, a potential customer choosing among Linux distributions, liked
to use a program, and I saw on the program home page that so-and-so
distributions included the program, I would arrange my preference
accordingly.

If I, an absent-minded user, heard about some great program from my
friends, and saw on the program home page which distributions included
it, I might realize Gosh, *my* distribution CD already has it! and
save some download and install effort.  Remember, I am absent-minded,
so I wouldn't know what's on my CD unless someone stick it on my
face. :)

I probably don't need hyperlinks; I just need to know if my
distribution includes it or not.
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: i368-pc-os2-emx port

2002-02-20 Thread Albert Lai

Simon Marlow [EMAIL PROTECTED] writes:

 On the other hand, you'd need something like mingw for OS/2 - does
 such a beast exist?

The substring emx refers to an OS/2 version of gcc and libraries
that make OS/2 look really like Unix from the programmer's point of
view.  (It probably even pre-dates cygwin.)  I have two encouraging
stories to tell.  First, for a school assignment, I wrote an OpenGL
program on emx, then ported it to school's Solaris+Mesa ten minutes
before the deadline --- where porting meant removing #include
os2.h.  Second, I wrote a program that used tcpip sockets on Unix,
then merely recompiled it on emx to use it on OS/2 as well.

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Congrats to Mandrake

2002-02-20 Thread Dylan Thurston

On Wed, Feb 20, 2002 at 03:45:15PM +0200, Lauri Alanko wrote:
 On Wed, Feb 20, 2002 at 01:37:52PM -, Simon Marlow wrote:
  Could someone who is Debian-compliant tell me where I should be pointing
  for Debian packages?
 
 http://ftp.debian.org/debian/pool/main/g/ghc5/
 
 Though of course any debian user should just be able to say apt-get install
 ghc5 to get the latest package from the nearest mirror...

Better:

http://packages.debian.org/testing/devel/ghc5.html
http://packages.debian.org/unstable/devel/ghc5.html

--Dylan Thurston



msg03123/pgp0.pgp
Description: PGP signature


Haskell 98 Report

2002-02-20 Thread David Feuer

Is the revised Haskell98 report going to be put in its proper place on
the web site any time soon?  As it is, it is sitting off to the side
while the old Report sits in the seat of honor.

David Feuer
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Final CFP : FLOPS'02 / ASIA-PEPM'02

2002-02-20 Thread Zhenjiang Hu

===
The submission deadline for ASIA-PEPM'02 and FLOPS'02 
has ben extended until March 8, 2002.
===

   FINAL CALL FOR PAPERS 

ASIAN Symposium on
  Partial Evaluation and Semantics-Based Program Manipulation
   http://www.comp.nus.edu.sg/asia-pepm02

   International Symposium on Functional and Logic Programming 
 http://www.ipl.t.u-tokyo.ac.jp/FLOPS2002/
   
   Aizu, JAPAN, September 12-17 2002

***

IMPORTANT DATES:

Submission Deadline: March 8, 2002  
Notification:May 21, 2002
Final Version:   June 25, 2002   
Conferences: September 12-17, 2002  

***


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



RE: Haskell 98 Report

2002-02-20 Thread Simon Peyton-Jones

I don't want to do that until its finished!
Which I earnestly hope will be soon.

Simon

| -Original Message-
| From: David Feuer [mailto:[EMAIL PROTECTED]] 
| Sent: 20 February 2002 08:43
| To: [EMAIL PROTECTED]
| Subject: Haskell 98 Report
| 
| 
| Is the revised Haskell98 report going to be put in its proper 
| place on the web site any time soon?  As it is, it is sitting 
| off to the side while the old Report sits in the seat of honor.
| 
| David Feuer
| ___
| Haskell mailing list
| [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
| 
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



RE: foralls in class assertions

2002-02-20 Thread Simon Peyton-Jones

OK, so it does look as though it's the same idea as 
that described in our paper.   Good.

I have not implemented, yet.  As always my implementation
priorities are strongly influenced by my perception of whether
some enhancement would be used.  Maybe you can outline
why such a change would be useful to you?  I only have the
example in our paper as motivation so far.

Simon

| -Original Message-
| From: Ashley Yakeley [mailto:[EMAIL PROTECTED]] 
| Sent: 20 February 2002 01:08
| To: Simon Peyton-Jones; Haskell List
| Subject: RE: foralls in class assertions
| 
| 
| At 2002-02-19 09:21, Simon Peyton-Jones wrote:
| 
| I don't know if it makes sense.   You've written down some syntax,
| but it's not clear to me what you intend by it.
| 
| Hmm... it should be straightforward...
| 
|  instance (forall a. Eq a = Eq (f a)) = Eq (Rose f a) where..
| 
| I assume that the 'a' quantified in (forall a. ...) is not 
| the same as 
| the 'a' in 'Rose f a'?
| 
| | instance
| | (
| | forall a. HasIdentity (m a a),
| | forall a b c. Composable (m b c) (m a b) (m a c)
| | ) =
| |  Category m;
| 
| This means 'if for all a, HasIdentity (m a a), and also for 
| all a b c, 
| Composable (m b c) (m a b) (m a c), then Category m'.
| 
| (forall a. HasIdentity (m a a)) as a class assertion declares a 
| property of m. It says that for all types a, there's an instance 
| HasIdentity (m a a).
| 
| | Or even allow the foralls their own context:
| | 
| | foo :: (forall a. (C a b) = D a c) = T b c;
| 
| This means foo has type (T b c), where for every type a for 
| which there's 
| an instance C a b, there's an instance D a c.
| 
| | class
| | (
| | forall a. HasIdentity (m a a),
| | forall a b c. Composable (m b c) (m a b) (m a c)
| | ) =
| |  Category m;
| 
| Personally I think the 'superclass' arrow in class 
| declarations should 
| point the other way, as in '='. After all, instances of the 
| class imply 
| instances of the superclasses, not the other way around.
| 
| But that aside, this means 'Category is a class on m, 
| provided that for 
| all types a, there's an instance HasIdentity (m a a), and 
| also for all 
| types a b c, there's an instance Composable (m b c) (m a b) 
| (m a c)'.
| 
| 
| -- 
| Ashley Yakeley, Seattle WA
| 
| ___
| Haskell mailing list
| [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
| 
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: forcing IO operations

2002-02-20 Thread Andre W B Furtado

 liftIOtoMyMonad_ :: IO () - MyMonad ()
 liftIOtoMyMonad_ m   = liftIOtoMyMonad' (const m) ()

I'm having problems compiling this one: The last statement in a 'do'
construct must be an expression

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: forcing IO operations

2002-02-20 Thread Andre W B Furtado

[answering myself...]


  liftIOtoMyMonad_ :: IO () - MyMonad ()
  liftIOtoMyMonad_ m   = liftIOtoMyMonad' (const m) ()

 I'm having problems compiling this one: The last statement in a 'do'
 construct must be an expression

The problem is not related with liftIOtoMyMonad_ , but with liftIOtoMyMonad
and liftIOtoMyMonad'. I think its an identation problem. Re-writing these
funcions as follows solves the problem:

liftIOtoMyMonad' :: (a - IO ()) - a - MyMonad ()
liftIOtoMyMonad' p q =
 StateMonad $ \s - (do p q
return ((),s))

liftIOtoMyMonad  :: IO a - MyMonad a
liftIOtoMyMonad p=
 StateMonad $ \s - (do y - p
return (y,s))


At least by now, all the ideas are working very well... great help Jay,
thanks a lot!

-- Andre

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: forcing IO operations

2002-02-20 Thread Jay Cox

On Thu, 21 Feb 2002, Andre W B Furtado wrote:

  liftIOtoMyMonad_ :: IO () - MyMonad ()
  liftIOtoMyMonad_ m   = liftIOtoMyMonad' (const m) ()

 I'm having problems compiling this one: The last statement in a 'do'
 construct must be an expression


No problems here using no flags either.  ghc-5.00
Hmmm... hugs Feb2001 seems to complain about my source (different reason).

Which version of which compiler?

(Btw, upon further review I cant think of a good reason for that function
to exist.  liftIOtoMyMonad can do anything liftIOtoMyMonad_ can handle.
Essentially liftIOtoMyMonad_ = liftIOtoMyMonad but with a much more
restrictive type)


Jay Cox


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Monadic Call/CC?

2002-02-20 Thread Ashley Yakeley

Has anyone investigated monadic call-with-current-continuation in 
Haskell? Given this:

class (Monad m) = PeirceMonad m where
{
peirceM :: ((a - m b) - m a) - m a;
};

...which Monads can be made PeirceMonads?

The corresponding non-monadic function:

peirce :: ((a - b) - a) - a;

probably can't be defined.


-- 
Ashley Yakeley, Seattle WA

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: a universal printer for Haskell?

2002-02-20 Thread Johan Jeuring

 My point is that there are some things that can't easily be expressed
 in current Haskell (like generic printing) that are useful and
 might be aided by meta-programming technology. The interesting question
 is can it be done in a way that preserves whatever we want from the type
 system: safety, security, efficiency, error detection ...

You don't need meta-programming technology (reflection) to do things like
generic prinitng. A generic programming extension of Haskell (like
Generic Haskell, or derivable classes) can do the job for you.

Have a look at:

http://www.generic-haskell.org/

-- Johan

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



Re: a universal printer for Haskell?

2002-02-20 Thread C.Reinke

 You don't need meta-programming technology (reflection) to do things like
 generic prinitng. A generic programming extension of Haskell (like
 Generic Haskell, or derivable classes) can do the job for you.

Isn't generic programming usually based on a kind of compile-time
reflection (if the argument is of this type, do this, else..)?

And don't you write generic functions with the intention that the
implementation will figure out the approriate type-specific
variants, i.e., you write your code at a level of abstraction that
is not easily reached with the standard language tools -- a meta
level, where functions at different types are the first-class
objects of discourse?

I find it helpful to think of generic programming support as one way
of integrating well-behaved subsets of reflection and other
meta-programming techniques into Haskell. 

It is partly a trade-off: you get some of the features and avoid
some of the problems of a fully reflective architecture. It is also
a specialisation: by avoiding the full generality, the specific
subset of features can be designed in a structured fashion, with the
application domain in mind, making them easier to use for that domain.

Claus

(another fan of reflection and meta-programming, who would like to
 get their advantages without their disadvantages -- the latter are
 more clearly visible in a pure functional language than in Lisp)
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: a universal printer for Haskell?

2002-02-20 Thread Johan Jeuring

 You don't need meta-programming technology (reflection) to do things 
 like
 generic prinitng. A generic programming extension of Haskell (like
 Generic Haskell, or derivable classes) can do the job for you.

 Isn't generic programming usually based on a kind of compile-time
 reflection (if the argument is of this type, do this, else..)?

Yes, you might view it as compile-time reflection. Programs
are still typable.

 And don't you write generic functions with the intention that the
 implementation will figure out the approriate type-specific
 variants, i.e., you write your code at a level of abstraction that
 is not easily reached with the standard language tools -- a meta
 level, where functions at different types are the first-class
 objects of discourse?

If you view that as a metalevel I agree. However, it is the intention
you never see the generated functions at different types: the compiler
can (in priciple) completely hide those from the programmer. In that
sense there is just one level: Generic haskell offers you normal
Haskell functions and generic functions.

 I find it helpful to think of generic programming support as one way
 of integrating well-behaved subsets of reflection and other
 meta-programming techniques into Haskell.

 It is partly a trade-off: you get some of the features and avoid
 some of the problems of a fully reflective architecture. It is also
 a specialisation: by avoiding the full generality, the specific
 subset of features can be designed in a structured fashion, with the
 application domain in mind, making them easier to use for that domain.

Agreed.

-- Johan

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



RE: Survival of generic-classes in ghc

2002-02-20 Thread Simon Peyton-Jones

| and I know from testing earlier versions that the 
| generic-classes support was pretty buggy. Is there any hope 
| of a revival? Does it already work in CVS? I suspect it will 
| rot away if nobody works on it.
| 
| Any comments from the implementors - does the idea fit well 
| with ghc? Is it a lot of work to make it more stable?

No, it should not be a lot of work to revive, and I will do it.
Keep bugging me until I do. 

One thing that is slowing me down is a design uncertainty: how to deal
cleanly with constructors.  To write read, show, etc, one needs access
to
the constructor name, fixity etc.  We dance around that a little in the
paper.
I'm thinking of this design:

-- An example data type
data List a = Nil | Cons a (List a)

-- The ring type derived from it
-- Note the Con wrapped around the constructors
data ListO a = Con NilT 1 :+: Con ConsT (a :*: List a)

-- Con is part of the Generics library, like 1, :*:, :+:
newtype Con c a = Con a

class ConCls c where
   name :: c - String
   arity :: c - Arity
   ..etc..

data NilT   -- Phantom types
data ConsT  -- one per constructor

instance ConCls NilT where
   name _ = Nil
   ...etc...

instance ConCls ConsT wher
name _ = Cons
   ...etc...

Now you can write

   class Show a where
  show :: a - String
  show {| Con c t |} (Con x) = (name (undefined::c)) ++ show x
...etc..


Note the undefined::c; it is really just a type argument to name, so

that we get the string for the right constructor.  It's a bit clunky,
though.
Another possiblity would be to make the ConCls class look like this
class ConCls c where
  name :: String
  arity :: Int 
  ...etc...

Now we'd have to give an explicit type argument at the call site:

  show {| Constr c t |} (Con x) = (name {| c |}) ++ show x

I quite like the thought of being able to supply explicit type
arguments
but I don't konw how to speak about the order of type parameters.
What order does map takes its two type parameters in?


Another question is whether we need an indication that we have reached 
a field of the constructor.  Should we have:

data ListO a = Con NilT (Field 1) :+: Con ConsT (Field a :*: (Field List
a))

newtype Field a = Field a


Without this, it's hard to write a generic function to count the number
of
fields of the data type.  But in general, one might want to know when
making the transition from this type to the argument types of  the
constructors.


I think that the main reason I'm not making much progress is that I
don't
know what design choices to make.  I'd be glad to discuss it with
interested
parties.

Simon
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: a universal printer for Haskell?

2002-02-20 Thread Eray Ozkural

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Wednesday 20 February 2002 08:46, Bernard James POPE wrote:

 There are numerous ways to provide security for your data types.

(In)Visibility isn't security. I have more than often witnessed Java users 
who thought private keyword was for security.

I think it's obvious, with many years of worldwide experience of Internet 
security, why obscurity is *not* security.

Thanks,

- -- 
Eray Ozkural (exa) [EMAIL PROTECTED]
Comp. Sci. Dept., Bilkent University, Ankara
www: http://www.cs.bilkent.edu.tr/~erayo
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8dCTGfAeuFodNU5wRAjGsAJ4tq8Nqg5Vh4pANHbMZ0JT+u1iVpgCcDY7i
PI0TC9Y+DnVAV8AstF2ovmk=
=+xqN
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Haskell problem

2002-02-20 Thread Mark Wotton

Hi,

I'm trying out some combinatorial parsers, and I ran into a slightly 
inelegant construction. To parse a sequence of things, we have a function 
like

pThen3 :: (a-b-c-d) - Parser a - Parser b - Parser c - Parser d
pThen3 combine p1 p2 p3 toks =
[(combine v1 v2 v3, toks3) | (v1, toks1) - p1 toks,
 (v2, toks2) - p2 toks1,
 (v3, toks3) - p3 toks2]

The problem with this is that this structure has to be duplicated for
pThen2, pThen4, and so on. These other forms are very similar to pThen3,
but there seems to be no way to capture this in Haskell's type system, as
the combine function has a different signature for each pThenX. (This is
actually the first time the Haskell type system has got in my way rather
than helping.) Is there a way around this problem?

mrak


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



Haskell problem

2002-02-20 Thread Tom Pledger

Mark Wotton writes:
 | Hi,
 | 
 | I'm trying out some combinatorial parsers, and I ran into a slightly 
 | inelegant construction. To parse a sequence of things, we have a function 
 | like
 | 
 | pThen3 :: (a-b-c-d) - Parser a - Parser b - Parser c - Parser d
 | pThen3 combine p1 p2 p3 toks =
 | [(combine v1 v2 v3, toks3) | (v1, toks1) - p1 toks,
 |  (v2, toks2) - p2 toks1,
 |  (v3, toks3) - p3 toks2]
 | 
 | The problem with this is that this structure has to be duplicated for
 | pThen2, pThen4, and so on. These other forms are very similar to pThen3,
 | but there seems to be no way to capture this in Haskell's type system, as
 | the combine function has a different signature for each pThenX. (This is
 | actually the first time the Haskell type system has got in my way rather
 | than helping.) Is there a way around this problem?

If you can build the list of tokens into the state of your Parser
monad - which would include making  Parser a  a distinct type instead
of an alias for  [Token] - [(a, Token)]  - you could condense pThen3
down to this:

pThen3 combine p1 p2 p3 toks
= do v1 - p1
 v2 - p2
 v3 - p3
 return (combine v1 v2 v3)

which is equivalent to the liftM3 function from the Monad library.
You'd still be stuck with a family of lifting functions, but at least
they're predefined.  I don't see any way of getting by with a fixed
number of lifting functions, unless you're willing to clutter the call
sites:

infixl 0 `ap`
ap :: Parser (a - b) - Parser a - Parser b
ap = Monad.ap
...
... Monad.liftM f p1 `ap` p2 `ap` p3 `ap` p4

Regards,
Tom
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Survival of generic-classes in ghc

2002-02-20 Thread Dylan Thurston

On Wed, Feb 20, 2002 at 01:15:36PM -0800, Simon Peyton-Jones wrote:
 Another possiblity would be to make the ConCls class look like this
   class ConCls c where
 name :: String
 arity :: Int 
 ...etc...
 
 Now we'd have to give an explicit type argument at the call site:
 
   show {| Constr c t |} (Con x) = (name {| c |}) ++ show x
 
 I quite like the thought of being able to supply explicit type
 arguments
 but I don't konw how to speak about the order of type parameters.
 What order does map takes its two type parameters in?

Sorry, this seems like a non-sequitur to me?

'map' has type '(a-b) - [a] - [b]'; supplying explicit type
parameters would mean giving values to 'a' and 'b'.  If I wanted to
propose notation for this, I would suggest, e.g.,
  (map :: (String - Int) - [String] - [Int]) length [Hello, World]

'name' (above) has type 'String'; the '{| c |}' is not providing a type
parameter in the same sense.

What am I missing?

Best,
Dylan



msg01379/pgp0.pgp
Description: PGP signature