Why are Hugs complaining about `` in my data type declaration?

I am in the process of writing a small lisp translator in haskell. In the process, I defined this data type to get a less typed number.

data Number = _Int Integer
            | _Rational Rational
            | _Float Double
    deriving(Eq,Show)

Compilation with error errors with the following error:

ERROR "types.hs": 16 - Syntax error in data type declaration (unexpected `| ')

Line 16 is the line with the first |in the code above.

+3
source share
1 answer

. |, - . , , Haskell.

, Hugs "", , , , , Hugs : ", ! ?"

GHC :

types.hs:1:14: Not a constructor: `_Int'
+13

Source: https://habr.com/ru/post/1737439/


All Articles