Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I really hope there would be a ML-like syntax for Rust. The current one is not so friendly to read.


Agree -- these days whenever I try to pick between Haskell and Rust for a new project I go Haskell because of the much nicer syntax (though it took some getting used to).

I also have almost 0 interest in OCaml due to the syntactic choices they've made.


I use OCaml and I am also writing my own ML dialect, so I would like to ask, what exact aspects of the OCaml syntax don't you like, and what parts of the Haskell syntax do you like in particular? (For example, do you prefer indentation-based syntax?)


I honestly don't know how to explain it really well, but OCaml is much noisier than Haskell in my opinion. Many times when I see code snippets in OCaml they're not as nice as they look in Haskell, though they're really similar. The small difference seems to snowball when the code gets increasingly complicated.

Compare functor's definitions in either syntax:

     module type FUNCTOR = sig
       type 'a t
       val map : ('a -> 'b) -> 'a t -> 'b t
     end;;

     class Functor where
      fmap        :: (a -> b) -> f a -> f b
The latter looks cleaner to me. There are other ways you could write it (for example if you turned on explicit forall it would get messier.

At this point I start skipping talks at conferences when they're in Scala because the amount of noise in the syntax is near unbearable to me (and there's likely to be a haskell talk on a similar topic) -- OCaml is much better in that respect, but I still find Haskell's syntax to be easiest on the eyes. OCaml might be more pedantically descriptive though, it seems to be more explicit about everything.


>but OCaml is much noisier than Haskell in my opinion.

I would rather say explicit, and that was a breath of fresh air to me after Haskell. As for your example, how many instances do you need to write all the type classes you need?

In OCaml I could just write all the functions I need in a file, and this file-module would implement all the signatures, thanks to the structural typing, now condiser:

    type 'a t
    val bind : 'a t -> ('a -> 'b t) -> 'b t
    val apply : ('a -> 'b) t -> 'a t -> 'b t
    val map : ('a -> 'b) -> 'a t -> 'b t
    val show : 'a t -> ('a -> string) -> string
    val return : 'a -> 'a t
instead of

    instance Functor a => Functor (Type a) where
       fmap        :: (a -> b) -> f a -> f b

    instance Applicative a => Applicative (Type a) where
       <*>         :: f (a -> b) -> f a -> f b

    instance Show (Type a) where
       show        :: a -> string

    instance Monad...

which is more verbose?


This is pretty nitpicky, but I really dislike the postfix syntax for type constructor application.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: