mirror of
https://github.com/google/ormolu.git
synced 2024-12-13 03:34:12 +03:00
5f5f9227aa
This pull request implements half of #49. Specifically, it deals with pretty printing instance declarations and most structures needed to support that. This includes pretty printing of associated types (and therefore also type family instances.) However, this _does not_ include pretty printing of associated data types. Pretty printing of type class declarations is to be dealt with at a later time. Instances are formatted such that indentation hangs after the `instance`. Namely, ```haskell instance Eq a => Eq [a] where ``` To support pretty printing associated types, the function `p_tyFamInstEqn` was exported from the appropriate module. This was done to avoid redundant code duplication.
26 lines
373 B
Haskell
26 lines
373 B
Haskell
{-# LANGUAGE InstanceSigs #-}
|
|
|
|
instance Eq Int
|
|
where
|
|
(==) :: Int -> Int -> Bool
|
|
(==) _ _ = False
|
|
|
|
instance Ord Int where
|
|
compare ::
|
|
Int
|
|
-> Int
|
|
-> Ordering
|
|
compare
|
|
_
|
|
_
|
|
= GT
|
|
|
|
instance Applicative [] where
|
|
pure ::
|
|
a
|
|
-> [a]
|
|
pure a = [a]
|
|
(<*>)
|
|
:: [ a ] -> [ a ] -> [ a ]
|
|
(<*>) _ _ = []
|