Sublime Forum

Two tweaks needed on Haskell's comments

#1

Hi!

I sometimes develop Haskell programs and I always use ST. There are two errors that I wish to be fixed when you can:

  1. When you use the “toogle comment” option of ST, it just inserts two dashes in the beginning of each marked line. There are situations where you get a GHC error for doing this, so I think is better to put two dashes followed by one space on each line, to prevent those errors (sorry I don’t find any GHC error use case, I’ve tried to and all my code compiles :(). Anyways, taking a look on the Traversable typeclass code on Hackage you can see they put a space after the two dashes on each line. I consider that the best practice for single line comments and I always do it that way.

  2. ST does not hightlight well code snippers like:

    {-
    class (Functor t, Foldable t) => Traversable t where
    {-# MINIMAL traverse | sequenceA #-}

    – | Map each element of a structure to an action,
    – evaluate these actions from left to right, and
    – collect the results. For a version that ignores
    – the results see ‘Data.Foldable.traverse_’.
    traverse :: Applicative f =>
    (a -> f b)
    -> t a
    -> f (t b)
    traverse f = sequenceA . fmap f
    – | Evaluate each action in the structure from
    – left to right, and collect the results.
    – For a version that ignores the results see
    – ‘Data.Foldable.sequenceA_’.
    sequenceA :: Applicative f => t (f a) -> f (t a)
    sequenceA = traverse id
    -}

On that code, there is a pragma indicating that the Foldable typeclass must be instantiated implementing one of those two methods. A pragma in Haskell has the form {-# PragmaName #-}. But the comments parser that ST uses does not parse that like a pragma expression but like the comment end -} and so the highlighting is incorrect. I see on ST code like not commented when it really is, and the code compiles fine.

0 Likes

#2

I think here is the correct place to report syntax issues with the shipped packages:

0 Likes