RE: [Haskell] deriving with newtypes

2004-04-06 Thread Brandon Michael Moore
On Fri, 2 Apr 2004, Simon Peyton-Jones wrote: > Your word is my command. 'Tis done. > > Simon > > | -Original Message- > | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Wolfgang > | Jeltsch > | Sent: 21 March 2004 17:55 > | To: The Haskell Mailing List > | Subject: [Ha

Re: [Haskell] What is the best way to write adapters?

2004-03-11 Thread Brandon Michael Moore
On Thu, 11 Mar 2004 [EMAIL PROTECTED] wrote: > > Thanks! Oleg. > > This works and it looks nice! > > And now, my code can be like: > > class FwdSig d where > (forall a. Sig a => a -> w) -> d -> w > > All the types that supports such forwarding are instances of FwdSig. > > My Def type is: > > in

[Haskell] Re: [Haskell-cafe] matching constructors

2004-03-08 Thread Brandon Michael Moore
I think the generics approach really is overkill here, but it's nice to know the generics library. For option processing Tomasz Ziolonka described a nice technique in the post I refered to. You can find the post in the archives at http://www.haskell.org//pipermail/haskell/2004-January/013412.html

RE: [Haskell] Per-type function namespaces (was: Data.Set whishes)

2004-02-27 Thread Brandon Michael Moore
On Fri, 27 Feb 2004, Simon Peyton-Jones wrote: > > The idea that I've been throwing around is to be able to define a > > separate namespace for each type; a function can either belong in a > > "global" (default) namespace, or belong in a particular type's > > namespace. So, in the above example

Re: [Haskell] Per-type function namespaces (was: Data.Set whishes)

2004-02-26 Thread Brandon Michael Moore
On Fri, 27 Feb 2004 [EMAIL PROTECTED] wrote: > On 27/02/2004, at 1:13 PM, [EMAIL PROTECTED] wrote: > > 1) now I have to manually declare a class definition for every single > function, and I have to declare it in advance before any module defines > that function (most serious problem; see below),

Re: type classes, superclass of different kind

2003-12-11 Thread Brandon Michael Moore
On Thu, 11 Dec 2003, Robert Will wrote: > Hello, > > As you will have noticed, I'm designing a little library of Abstract Data > Structuresm here is a small excerpt to get an idea: > > class Collection coll a where > ... > (<+>) :: coll a -> coll a -> coll a > reduce :: (a -> b) -> b

Re: Functional dependencies interfere with generalization

2003-11-27 Thread Brandon Michael Moore
On Wed, 26 Nov 2003, Ken Shan wrote: > Hello, > > Consider the following code, which uses type classes with functional > dependencies: > > {-# OPTIONS -fglasgow-exts #-} > module Foo where > class R a b | a -> b where r :: a -> b > > -- 1 > rr :: (R a b1, R a b2) => a -> (b1,

Re: a type question

2003-11-26 Thread Brandon Michael Moore
It depends what sort of polymorphism you want theta to have. If your function types involve concrete types you could write something like type IntMap = Int -> Bool -> String and then say theta :: IntMap -> Int -> String If you want the argument function to be completely polymorphic you can say t

type class problem / GHC bug

2003-11-08 Thread Brandon Michael Moore
Hi everyone I've built GHC from CVS and I'm getting some odd errors about overlapping instances. This is different from 6.0.1, but it's not obvious it is wrong, so I'm probably missing something here. The example is class A x class (A x) => B x instance A x instance B x The new GHC complains th

Re: Polymorphic Recursion / Rank-2 Confusion

2003-09-21 Thread Brandon Michael Moore
On Sun, 21 Sep 2003, Dominic Steinitz wrote: > > Brandon, > > I get the error below without the type signature. My confusion was thinking > I needed rank-2 types. In fact I only need polymorphic recursion. Ross > Paterson's suggestion fixes the problem. I stole Even and Odd from Chris > Okasaki's

Re: Polymorphic Recursion / Rank-2 Confusion

2003-09-20 Thread Brandon Michael Moore
Sorry about the empty message. Send /= Cancel > Can anyone tell me why the following doesn't work (and what I have to do to > fix it)? I thought by specifying the type of coalw as rank-2 would allow it > to be used both at a and (a,b). Frank explained why the type you gave wouldn't work. I would

Re: Polymorphic Recursion / Rank-2 Confusion

2003-09-20 Thread Brandon Michael Moore
On Sat, 20 Sep 2003, Ross Paterson wrote: > On Sat, Sep 20, 2003 at 12:01:32PM +0100, Dominic Steinitz wrote: > > Can anyone tell me why the following doesn't work (and what I have to do to > > fix it)? I thought by specifying the type of coalw as rank-2 would allow it > > to be used both at a and

Re: Syntax extensions: mdo and do...rec

2003-09-17 Thread Brandon Michael Moore
Sorry, I forgot the main question I was raising. Even if we need something other than mdo, do we need to make a distinction between do and mdo? If left tightening is satisfied then do and mdo are equivalent for nonrecursive blocks. If we are willing to give up shadowing a compiler could translate

Re: Syntax Extensions (and future Haskell)

2003-09-17 Thread Brandon Michael Moore
On Thu, 18 Sep 2003 [EMAIL PROTECTED] wrote: > Although a number of comments in this discussion make some sense, > I personally am getting worried about the direction that it is taking. > I have been a (fairly quiet) Haskell user for some time. I like it > because of the strong connection to stan

Re: Syntax extensions: mdo and do...rec

2003-09-17 Thread Brandon Michael Moore
x27;s thesis. > On Wed, Sep 17, 2003 at 11:41:24AM -0700, Brandon Michael Moore wrote: > > In any case, I don't see the need for explicit rec groups. Can't GHC just > > find the strongly connected components like it already does with let > > bindings? > > Th

Re: Syntax extensions: mdo and do...rec

2003-09-17 Thread Brandon Michael Moore
> hello, > i have no strong feelings about that either way, > however since in haskell we do not have "let" vs "let rec" distinctions, > perhaps we should not have "do" vs "do rec" distinction. > this of course would break programs relying on shadowing > (and at least i write quite a few of those

Re: Question about implementation of an "information-passnig" arrow

2003-09-16 Thread Brandon Michael Moore
On Mon, 15 Sep 2003, Yu Di wrote: > data MyArrow a b = MyArrow ((String, a) -> (String, > b)) > > i.e. there is an "information" asscioated with each > piece of data (represented by the string), and I want > to pass it around. And often the arrow's processing > logic will depend on the input inf

RE: Circular Instance Declarations

2003-09-14 Thread Brandon Michael Moore
On Thu, 11 Sep 2003, Simon Peyton-Jones wrote: > OK, I yield! > > The HEAD now runs this program. It turned out to be a case of > interchanging two lines of code, which is the kind of fix I like. > > Simon Cool! Yet another domain where haskell handles infinities quite happily. Thanks. Hopefu

Re: Circular Instance Declarations

2003-09-10 Thread Brandon Michael Moore
On Wed, 10 Sep 2003, Ashley Yakeley wrote: > Brandon Michael Moore <[EMAIL PROTECTED]> wrote: > > > A simple irregular type is > > Irr a = Con a (Irr (F a)) > > (as long as F uses a) > > Would this be an irregular type, with F as ((->) val)

Request for Instances

2003-09-10 Thread Brandon Michael Moore
Hi everyone. I've been looking at the restrictions on instances in the H98 standard and thinking about alternatives. I would like to have a body of data type and class/instance declarations so I can test how useful various extensions would be. Please send or direct me to code that requires -fallo

Type Class Problem

2003-09-10 Thread Brandon Michael Moore
Hello everyone I think I'm close to useful results on the instance restrictions. First there's an obvious extension to the Haskell98 rule. The H98 rule says the instance head must be a type constructor applied to type variables, and the context must mention only those type variables. This gives a

Re: Circular Instance Declarations

2003-09-10 Thread Brandon Michael Moore
On Sun, 7 Sep 2003, Ashley Yakeley wrote: > In article <[EMAIL PROTECTED]>, > Brandon Michael Moore <[EMAIL PROTECTED]> wrote: > > > Detecting circularity in a derivation is equivalent to accepting a regular > > infinite derivation for instances. W

Re: Circular Instance Declarations

2003-09-07 Thread Brandon Michael Moore
Hi Ashley See the thread "Type Class Problem". In his post on Aug 22 Simon Peyton-Jones said that it shouldn't be hard to implement, and mentioned that it would ruin the property that dictionaries can be evaluated by call-by-value. I couldn't puzzle out enough of the type class system to make th

RE: Type class problem

2003-08-30 Thread Brandon Michael Moore
On 28 Aug 2003, Carl Witty wrote: > On Thu, 2003-08-28 at 13:10, Brandon Michael Moore wrote: > > Unfortunately I don't have a useful syntatic condition on instance > > declarations that insures termination of typechecking. If types are > > restriced to products, su

RE: Type class problem

2003-08-28 Thread Brandon Michael Moore
On Fri, 22 Aug 2003, Simon Peyton-Jones wrote: > > Brandon writes > > | An application of Mu should be showable if the functor maps showable > types > | to showable types, so the most natural way to define the instance > seemed > | to be > | > | instance (Show a => Show (f a)) => Show (Mu f) wher

Re: Type class problem

2003-08-17 Thread Brandon Michael Moore
On Sun, 17 Aug 2003 [EMAIL PROTECTED] wrote: > > > I defined type recursion and naturals as > > > >newtype Mu f = In {unIn :: f (Mu f)} > > >data N f = S f | Z > > >type Nat = Mu N > > > An application of Mu should be showable if the functor maps showable types > > to showable types, so the most

Type class problem

2003-08-14 Thread Brandon Michael Moore
To try some of the examples from paper "Recursion Schemes from Comonads", I wanted to define instances of Show and Observable for types defined as the fixed point of a functor. I defined type recursion and naturals as >newtype Mu f = In {unIn :: f (Mu f)} >data N f = S f | Z >type Nat = Mu N An

Re: Calling Haskell from Java

2003-08-14 Thread Brandon Michael Moore
Is it fine if the interface uses JNI? The jvm-bridge is an excellent tool if you can use JNI, but I don't know of anything that compiles Haskell to java bytecode. There was a post a few years ago about an experimental Java backend for GHC, but I haven't heard anything since, and the -J switch doesn

RE: Help with Exceptions on I/O

2003-08-14 Thread Brandon Michael Moore
You don't really need to change the buffering mode. stdout is line buffered by default, so you just need to make sure a newline is printed after your message. putStrLn adds a newline after the string it prints, or you could use \n in the string literal. Try this: main = do --lots of code goes h