@@ -161,7 +161,7 @@ instance Pretty DeBruijn where
161161 pretty (DeBruijn i j) = "〚" <> pretty i <+> pretty j <> "〛"
162162
163163instance Pretty NType where
164− pretty t = greekifyWith t $ prettyNType t
164+ pretty t = greekifyWith t $ prettyNType False t
165165
166166instance Pretty Scheme where
167167 pretty t = greekifyWith t $ prettyScheme t
@@ -189,21 +189,21 @@ getDeBurjin (DeBruijn i j) = do
189189
190190type PrettyM a = forall eff. Members '[Reader Depth, Reader (Map DeBruijn Text)] eff => Eff eff a
191191
192−prettyNType :: NType -> PrettyM (Doc ann)
193−prettyNType (NTypeVariable x) = return $ pretty x
194−prettyNType (NBruijn x) =
192+prettyNType :: Bool -> NType -> PrettyM (Doc ann)
193+prettyNType _ (NTypeVariable x) = return $ pretty x
194+prettyNType _ (NBruijn x) =
195195 getDeBurjin x <&> \case
196196 Nothing -> pretty x
197197 Just t -> pretty t
198−prettyNType (NAtomic x) = return $ pretty x
199−prettyNType (x :-> y) = descend $ do
200− x' <- prettyNType x
201− y' <- prettyNType y
202− return $ group $ x' <+> "->" <> line <> y'
203−prettyNType (List x) = descend $ do
204− x' <- prettyNType x
198+prettyNType _ (NAtomic x) = return $ pretty x
199+prettyNType rhs (x :-> y) = descend $ do
200+ x' <- prettyNType True x
201+ y' <- prettyNType False y
202+ return $ group $ (if rhs then bracketed "(" ")" else id) $ x' <+> "->" <> line <> y'
203+prettyNType _ (List x) = descend $ do
204+ x' <- prettyNType True x
205205 return $ group $ bracketed "[" "]" x'
206−prettyNType (NAttrSet m) = descend $ do
206+prettyNType _ (NAttrSet m) = descend $ do
207207 decls <- prettyDecl `traverse` M.toAscList m
208208 return $ group $ bracketed "{" "}" $ vsep decls
209209 where
@@ -227,18 +227,18 @@ prettyScheme u@(Preds cs :=> t) = do
227227 prettyPred `traverse` cs <&> \case
228228 [] -> mempty
229229 cs' -> group (paren (vsep $ punctuate "," cs') <+> "=>" <> line)
230− t' <- prettyNType t
230+ t' <- prettyNType False t
231231 return $ group $ foralls <> cs' <> t'
232232 where
233233 prettyPred :: Pred -> PrettyM (Doc ann)
234234 prettyPred (h `HasField` (k, v)) = do
235− h' <- prettyNType h
235+ h' <- prettyNType False h
236236 v' <- prettyScheme v
237237 return $ group $ group (h' <> nest 2 (line' <> "." <> pretty k <+> "=")) <> nest 2 (line <> v')
238238 prettyPred (Update x y z) = do
239− x' <- prettyNType x
240− y' <- prettyNType y
241− z' <- prettyNType z
239+ x' <- prettyNType False x
240+ y' <- prettyNType False y
241+ z' <- prettyNType False z
242242 return $ group $ paren x' <+> "//" <> line <> paren y' <+> "~" <> line <> paren z'
243243 paren = bracketed "(" ")"
244244