mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-10 20:00:27 +03:00
automatically run ormolu
This commit is contained in:
parent
95dd8747ff
commit
a824eb8308
@ -28,6 +28,7 @@ import Unison.PrettyPrintEnv.FQN (Imports, elideFQN)
|
||||
import Unison.PrettyPrintEnv.MonadPretty (MonadPretty, getPPE, runPretty, willCapture)
|
||||
import Unison.Reference (Reference, pattern Builtin)
|
||||
import Unison.Referent (Referent)
|
||||
import Unison.Settings qualified as Settings
|
||||
import Unison.Syntax.NamePrinter (styleHashQualified'')
|
||||
import Unison.Type
|
||||
import Unison.Util.ColorText (toPlain)
|
||||
@ -36,7 +37,6 @@ import Unison.Util.Pretty qualified as PP
|
||||
import Unison.Util.SyntaxText qualified as S
|
||||
import Unison.Var (Var)
|
||||
import Unison.Var qualified as Var
|
||||
import Unison.Settings qualified as Settings
|
||||
|
||||
type SyntaxText = S.SyntaxText' Reference
|
||||
|
||||
|
@ -549,7 +549,7 @@ debugTrace e | debugEnabled = trace e False
|
||||
debugTrace _ = False
|
||||
|
||||
showType :: Var v => Type.Type v a -> String
|
||||
showType ty = TP.prettyStr (Just 120) PPE.empty ty
|
||||
showType ty = TP.prettyStr (Just 120) PPE.empty ty
|
||||
|
||||
debugType :: Var v => String -> Type.Type v a -> Bool
|
||||
debugType tag ty
|
||||
|
@ -361,7 +361,7 @@ allVars t = case out t of
|
||||
-- used within the term. See usage in `Type.normalizeForallOrder`
|
||||
numberedFreeVars :: (Ord v, Foldable f) => Term f v a -> Map v Int
|
||||
numberedFreeVars t =
|
||||
Map.fromList $ reverse (go mempty t `zip` [0..])
|
||||
Map.fromList $ reverse (go mempty t `zip` [0 ..])
|
||||
where
|
||||
go bound t = case out t of
|
||||
Var v -> if v `elem` bound then [] else [v]
|
||||
|
@ -741,15 +741,16 @@ freeVarsToOuters allowed t = foldr (introOuter (ABT.annotation t)) t vars
|
||||
|
||||
-- normalizes the order that variables are introduced by a forall
|
||||
-- based on the location where the variables first appear in the type
|
||||
normalizeForallOrder :: forall v a . (Var v) => Type v a -> Type v a
|
||||
normalizeForallOrder :: forall v a. (Var v) => Type v a -> Type v a
|
||||
normalizeForallOrder tm0 =
|
||||
foldr step body vs
|
||||
where
|
||||
step :: (a,v) -> Type v a -> Type v a
|
||||
step (a,v) body | Set.member v (ABT.freeVars body) = forall a v body
|
||||
| otherwise = body
|
||||
step :: (a, v) -> Type v a -> Type v a
|
||||
step (a, v) body
|
||||
| Set.member v (ABT.freeVars body) = forall a v body
|
||||
| otherwise = body
|
||||
(body, vs0) = extract tm0
|
||||
vs = sortOn (\(_,v) -> Map.lookup v ind) vs0
|
||||
vs = sortOn (\(_, v) -> Map.lookup v ind) vs0
|
||||
extract tm@(ABT.Tm' (Forall (ABT.Abs'' v body))) = ((ABT.annotation tm, v) :) <$> extract body
|
||||
extract body = (body, [])
|
||||
ind = ABT.numberedFreeVars body
|
||||
|
Loading…
Reference in New Issue
Block a user