Re[2]: Restricted Data Types: A reformulation

2006-02-08 Thread Bulat Ziganshin
Hello Jan-Willem, Wednesday, February 08, 2006, 4:26:48 PM, you wrote: JWM> Should there be a class which is implemented by every well-formed JWM> type of kind (*)? Should that class have one or more of the following: JWM>* Structural decomposition and reconstruction a la Generics? JWM>*

Re: Restricted Data Types: A reformulation

2006-02-08 Thread Jan-Willem Maessen
On Feb 7, 2006, at 11:45 PM, John Meacham wrote: Ashley Yakeley has convinced me this proposal won't work as is. I knew that dropping of the a type parameter in the dictionary passing scheme would bite me :). though, perhaps it will inspire another proposal? In the meantime, I will see about im

Re: Restricted Data Types: A reformulation

2006-02-07 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, John Meacham <[EMAIL PROTECTED]> wrote: > Ah. I think I see the objection now. Will have to think about it some. Here's a simpler example: class HasInt a where getInt :: a -> Int instance HasInt Int where getInt = id newtype HasInt a => T a = T

Re: Restricted Data Types: A reformulation

2006-02-07 Thread John Meacham
Ashley Yakeley has convinced me this proposal won't work as is. I knew that dropping of the a type parameter in the dictionary passing scheme would bite me :). though, perhaps it will inspire another proposal? In the meantime, I will see about implementing the 'wft' constraints as mentioned in the

Re: Restricted Data Types: A reformulation

2006-02-07 Thread John Meacham
Ah. I think I see the objection now. Will have to think about it some. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell-prime mailing list Haskell-prime@haskell.org http://haskell.org/mailman/listinfo/haskell-prime

Re: Restricted Data Types: A reformulation

2006-02-07 Thread John Meacham
I'll give the full desugaring, perhaps that will make it more clear: > foo :: (Monad m) => m Int > foo = return id >>= (\i -> return (i 7)) > > fooSet :: Set Int > fooSet = foo mkMonadDictSet :: EqDict a -> MonadDict Set eqDictInt :: EqDict Int return :: MoandDict m -> a -> m a foo :: Mona

Re: Restricted Data Types: A reformulation

2006-02-07 Thread John Meacham
On Tue, Feb 07, 2006 at 07:59:46PM -0800, Ashley Yakeley wrote: > John Meacham wrote: > > >however, (Set (a -> a)) is malformed. since a _requirement_ is that Set > >can only be applied to a type with an Eq constraint so the instance you > >try to do something like > > > >returnid :: Set (a -> a)

Re: Restricted Data Types: A reformulation

2006-02-07 Thread Ashley Yakeley
John Meacham wrote: however, (Set (a -> a)) is malformed. since a _requirement_ is that Set can only be applied to a type with an Eq constraint so the instance you try to do something like returnid :: Set (a -> a) -- ^ static error! you need returnid :: Eq (a -> a) => Set (a -> a) the instant

Re: Restricted Data Types: A reformulation

2006-02-07 Thread John Meacham
On Tue, Feb 07, 2006 at 05:54:51PM -0800, Ashley Yakeley wrote: > John Meacham wrote: > > >newtype Eq a => Set a = Set (List a) > >singleton :: Eq a => a -> Set a > >class Monad m where > >return :: a -> m a > > > >instance Monad Set where > >return x = singleton x > > > >okay, our

Re: Restricted Data Types: A reformulation

2006-02-07 Thread Ashley Yakeley
John Meacham wrote: newtype Eq a => Set a = Set (List a) singleton :: Eq a => a -> Set a class Monad m where return :: a -> m a instance Monad Set where return x = singleton x okay, our goal is to make this typesafe. You shouldn't be able to, should you? Monad makes a promis

Restricted Data Types: A reformulation

2006-02-07 Thread John Meacham
I am trying to reformulate restricted data types such that they can easily be implemented by jhc and possibly standardized independent of the implementation method and would like to run what I have so far by the list. Unlike the original paper, I will treat the user-visible changes to the type syst