Taral wrote:
On 9/11/06, Bulat Ziganshin <[EMAIL PROTECTED]> wrote:
      Expr Bool = Eq (Expr t) (Expr t) | forall t . Eq t

Still confusing, but less so.

The problem is that it's really backwards. The symbol being defined
is "Eq".
Eq (Expr t) (Expr t) | Eq t = Expr Bool

but that doesn't fit well, does it? In my mind, the current mode is a
functional one:

Eq :: Eq t => Expr t -> Expr t -> Expr Bool

And this is perfectly readable. The arrow means that the argument is
an implicit propositional one, but it's still an argument.

Perhaps the proposed new style of function signature could also be used in a GADT eg:

   -- There is no need for the keyword "Data" because we know it's part of
-- a GADT because the function name is a conid - all such decls in a module would
   -- then be gathered together to form the GADT(s)

   If    :: Expr Bool -> Expr t -> Expr t -> Expr t
   Eq  :: Expr t -> Expr t -> Expr Bool | Eq t
   Lit  :: Int -> Expr Int
or
   data
           Expr t         = If (Expr Bool) (Expr t) (Expr t)
           Expr Bool   = Eq (Expr t) (Expr t) | Eq t
           Expr Int      = Lit Int

The second option is of course backwards compared to a function declaration, but this is natural because there can only ever be one clause for each value constructor but mutiple clauses per result type, whereas in a function decl there can be multiple clauses for each pattern but only one result type, therefore function decls are inherently backwards wrt data decls...

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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to