Formatted file has invalid syntax for the associated type synonym defaults
Closed this issue · 2 comments
lykahb commented
Describe the bug
Ormolu removes the word "instance" in the output.
To Reproduce
Format this file
class IsBoolMap v where
type Key v
type instance Key v = Int
lookupKey :: Key v -> v -> Maybe Bool
The output would be
class IsBoolMap v where
type Key v
type Key v = Int -- Invalid syntax
lookupKey :: Key v -> v -> Maybe Bool
Expected behavior
This line preserves the word instance
:
type instance Key v = Int
Environment
- OS name + version: Mac OS X Sonoma
- Version of the code: 0.7.1.0
amesgen commented
You write
class IsBoolMap v where
type Key v
type Key v = Int -- Invalid syntax
AFAICT, both variants (with and without instance
) are valid (they both parse and compile just fine). From the GHC User's Guide:
- The
instance
keyword is optional.
Are you observing something different?
lykahb commented
I had an unrelated warning on that line and compiled with -Werror. At a glance the disappearing keyword looked like the source of it.