I was editing a Emacs syntax highlight and noticed it has been highlighting deriving
, because the code was derived from Haskell syntax highlight.
Now, I’ve never seen deriving
used in PureScript (PS has derive
instead). To be completely sure I decided to search over Github purescript files for the keyword, and… surprisingly, I did find code that is using it. However, I am not sure this code is valid, because the code looks more Haskellish despite being a .purs
file.
So I decided to test it manually. So, given this working code:
module Main where
import Effect (Effect)
import Prelude
data ContourType = ExternalContour | InternalContour
derive instance eqContourType :: Eq ContourType
main :: Effect Unit
main = pure unit
I replace it to:
module Main where
import Effect (Effect)
import Prelude
data ContourType = ExternalContour | InternalContour deriving (Eq)
main :: Effect Unit
main = pure unit
…and I get error: Unknown type Eq
. No complaints about the deriving
though, the compiler simply stopped seeing Eq
for some reason. So… what gives? Is it another instance of infamous PureScript compiler errors and the error should’ve been about the deriving
instead? Or is the syntax valid but… perhaps requires some quirks or whatnot to work?