Re: [Haskell] Re: Proposal: unification of style of function/data/type/class definitions

Hi
I don't see the problem. You can read all of Bulat's examples as "'thing being declared' 'relationship' 'value' given that 'context'", so this one is ""sequence" has type "[m a] -> m [a]" given that "m" is a "Monad"". So viewed that way, they're all consistent with each other.
How about name, context, value as the three elements: class <name> | <context> where <value> data <name> | <context> = <value> type <name> | <context> = <value> <name> | <context> :: <value> For class and data, you can argue that it isn't really a <value>, its <inner> or something. But type definately has a <value>. And if you want data and type consistent, you need to put them like that. And then, if you want functions consistent with types, you have to do the above. Or at least thats what my brain interprets as logical, and on the plus side it changes data/type/class which I personally don't like, but doesn't change function declarations, which I am not aware of anyone having issue with. Thanks Neil

Bulat Ziganshin wrote:
sequence :: [m a] -> m [a] | Monad m
I think translations of higher rank signatures using this syntax could be: foo :: (forall a. a-> a) ->b -> c -> (b,c) ==> foo :: (a -> a | a) -> b -> c -> (b, c) using the rule that we just write the variable by itself to indicate the quantification point. With restricted quantification, bar :: forall m a b. MonadIO m => (forall n. MonadIO n => a -> n b) -> a -> m b ==> bar :: (a -> n b | n, MonadIO n) -> a -> m b | a, b, m, MonadIO m Perhaps some rules could be devised to automatically determine the quantification point of each variable so it might even be possible to write the above as: bar :: (a -> n b | MonadIO n) -> a -> m b | MonadIO m though for MPTC it's no longer clear from a restriction which variable(s) are being introduced and which are being used as the basis for restricting them, hence explicit quantification as above is probably unavoidable for the general case. Neil Mitchell wrote:
How about name, context, value as the three elements:
class <name> | <context> where <value> data <name> | <context> = <value> type <name> | <context> = <value> <name> | <context> :: <value>
This would give: sequence | Monad m :: [m a] -> m [a] But this wouldn't work because here the context is separated from the rest of the type by :: whereas from the higher rank examples above it's clear that the context, which is nothing more than a(restricted) quantifier, needs to be part of the type itself. Regards, Brian. -- Logic empowers us and Love gives us purpose. Yet still phantoms restless for eras long past, congealed in the present in unthought forms, strive mightily unseen to destroy us. http://www.metamilk.com
participants (2)
-
Brian Hulley
-
Neil Mitchell