Skip to content

Commit

Permalink
Fix explicit forall in instances (closes #218)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Aug 26, 2016
1 parent b974955 commit c169a34
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 26 additions & 1 deletion TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ Type declaration
type EventSource a = (AddHandler a, a -> IO ())
```

Instance declaration without decls

``` haskell
instance C a
```

Instance declaration with decls

``` haskell
instance C a where
foobar = do
x y
k p
```

# Expressions

Lazy patterns in a lambda
Expand Down Expand Up @@ -364,7 +379,7 @@ main = putStrLn "Hello, World!"

## Regression tests

cocreature removed from declaration issue
cocreature removed from declaration issue #186

``` haskell
-- https://github.com/chrisdone/hindent/issues/186
Expand All @@ -376,6 +391,16 @@ trans One e n =
})
```

sheyll explicit forall in instances #218

``` haskell
-- https://github.com/chrisdone/hindent/issues/218
instance forall x. C

instance forall x. Show x =>
C x
```

# Behaviour checks

Unicode
Expand Down
6 changes: 4 additions & 2 deletions src/HIndent/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ decl (InlineSig _ inline _ name) = do
pretty name

write " #-}"
decl x = pretty' x
decl x' = pretty' x'

instance Pretty Deriving where
prettyInternal (Deriving _ heads) =
Expand Down Expand Up @@ -973,7 +973,9 @@ instance Pretty InstRule where
prettyInternal (IRule _ mvarbinds mctx ihead) =
do case mvarbinds of
Nothing -> return ()
Just xs -> spaced (map pretty xs)
Just xs -> do write "forall "
spaced (map pretty xs)
write ". "
withCtx mctx (pretty ihead)

instance Pretty InstHead where
Expand Down

0 comments on commit c169a34

Please sign in to comment.