diff --git a/src/Rlp/AltSyntax.hs b/src/Rlp/AltSyntax.hs index 81d2025..4f0529f 100644 --- a/src/Rlp/AltSyntax.hs +++ b/src/Rlp/AltSyntax.hs @@ -167,8 +167,10 @@ instance (Out b) => Out (DataCon b) where instance (Out b) => Out (Type b) where outPrec _ (VarT n) = ttext n outPrec _ (ConT n) = ttext n - outPrec p (s Core.:-> t) = maybeParens (p>appPrec-1) $ - hsep [ outPrec appPrec s, "->", outPrec (appPrec-1) t ] + outPrec p (s Core.:-> t) = maybeParens (p>arrPrec) $ + hsep [ outPrec arrPrec1 s, "->", outPrec arrPrec t ] + where arrPrec = appPrec-1 + arrPrec1 = appPrec outPrec p (AppT f x) = maybeParens (p>appPrec) $ outPrec appPrec f <+> outPrec appPrec1 x outPrec p FunT = maybeParens (p>0) "->" diff --git a/src/Rlp/HindleyMilner.hs b/src/Rlp/HindleyMilner.hs index ead950e..9696300 100644 --- a/src/Rlp/HindleyMilner.hs +++ b/src/Rlp/HindleyMilner.hs @@ -136,7 +136,7 @@ infer1' g1 e = do ((t,j) :< _) <- annotate e g2 <- unify (j ^. constraints) g <- unionContextWithKeyM unifyTypes g1 g2 - pure $ ifoldlOf (contextVars . itraversed) subst t g + pure $ ifoldrOf (contextVars . itraversed) subst t g where -- intuitively, we'd return mgu(s,t) but the union is left-biased making `s` -- the user-specified type: prioritise her.