[Haskell-cafe] an idea for modifiyng data/newtype syntax: use `::=` instead of `=`

Richard A. O'Keefe ok at cs.otago.ac.nz
Tue Aug 18 05:52:55 UTC 2015


On 9/08/2015, at 8:59 am, MigMit <miguelimo38 at yandex.ru> wrote:
> 
> The reason is very simple, and it was stated several times already: it will break everything that was written so far, and there is not enough evidence that things would be even a little better.

Not just everything written IN Haskell,
but everything written ABOUT Haskell as well.
Like books, lecture notes, tutorials, ...

For what it's worth,
 -- Ada
    type I1 is new Integer;    -- isomorphic but incompatible
    subtype I2 is Integer;     -- just an alias

(* ML *)
    datatype 'a tsil = LIN | SNOC of 'a tsil * 'a
    type revints = int stil
    (* spell the words backwards *)

// F#
    type T = A | B | C;;
    type R = T;;
    // How's that for confusing?  Defining a new type (T) and an
    // alias (R) use the *same* keyword and operator!
    type S = S;;  // defines a new type with one constructor, but
 // type S = T;;  // would have defined S as an alias for T.
% Mercury
    :- type strange
       ---> foo(int)
          ; bar(string).
    :- type wierd == strange.  % different operator.
% Erlang
    -type tsil(T)   :: nil | {snoc,tsil(T),T}.
    -type revints() :: tsil(integer()).
    % This looks as bad as F#, but it's either better or worse,
    % depending on your viewpoint.  Erlang types are not
    % Hindley-Milner types and it does not have ADT (sum-of-
    % products) declarations.  'snoc' above is just a constant.
    % BOTH declarations are aliases.
// Clean
    ::Tsil a = Lin | Snoc (Tsil a) a
    ::RevInts :== Tsil Int  //different operator

"::" is used to *introduce* a type in Clean, presumably
because infix "::" is used to *apply* a type (Empty :: RevInts).

Haskell is actually pretty clear.







More information about the Haskell-Cafe mailing list