|
|
@ -6,9 +6,11 @@ import Control.Arrow (Arrow(first)) |
|
|
|
|
|
|
|
import qualified Data.Map.Strict as Map |
|
|
|
import qualified Data.Text.Lazy as L |
|
|
|
import qualified Data.Set as Set |
|
|
|
import qualified Data.Text as T |
|
|
|
import Data.Map.Strict (Map) |
|
|
|
import Data.Text (Text) |
|
|
|
import Data.Set (Set) |
|
|
|
import Data.Generics |
|
|
|
|
|
|
|
import Presyntax.Presyntax (Plicity(..)) |
|
|
@ -43,8 +45,14 @@ prettyTm = prettyTm . everywhere (mkT beautify) where |
|
|
|
|
|
|
|
(al, bod) = unwindLam l |
|
|
|
|
|
|
|
prettyArgList (Ex, v) = pretty v |
|
|
|
prettyArgList (Im, v) = braces (pretty v) |
|
|
|
used = freeVars bod |
|
|
|
|
|
|
|
prettyArgList (Ex, v) |
|
|
|
| v `Set.member` used = pretty v |
|
|
|
| otherwise = pretty "_" |
|
|
|
prettyArgList (Im, v) |
|
|
|
| v `Set.member` used = braces $ pretty v |
|
|
|
| otherwise = pretty "_" |
|
|
|
|
|
|
|
prettyTm (Meta x) = keyword $ pretty '?' <> pretty (mvName x) |
|
|
|
prettyTm Type{} = keyword $ pretty "Type" |
|
|
@ -140,3 +148,47 @@ showValue = L.unpack . renderLazy . layoutSmart defaultLayoutOptions . prettyTm |
|
|
|
showFace :: Map Head Bool -> Doc AnsiStyle |
|
|
|
showFace = hsep . map go . Map.toList where |
|
|
|
go (h, b) = parens $ prettyTm (quote (VNe h mempty)) <+> operator (pretty "=") <+> pretty (if b then "i1" else "i0") |
|
|
|
|
|
|
|
freeVars :: Term -> Set Name |
|
|
|
freeVars (Ref v) = Set.singleton v |
|
|
|
freeVars (App _ f x) = Set.union (freeVars f) (freeVars x) |
|
|
|
freeVars (Pi _ n x y) = Set.union (freeVars x) (n `Set.delete` freeVars y) |
|
|
|
freeVars (Lam _ n x) = n `Set.delete` freeVars x |
|
|
|
freeVars (Let ns x) = Set.union (freeVars x `Set.difference` bound) freed where |
|
|
|
bound = Set.fromList (map (\(x, _, _) -> x) ns) |
|
|
|
freed = foldr (\(_, x, y) -> Set.union (Set.union (freeVars x) (freeVars y))) mempty ns |
|
|
|
freeVars Meta{} = mempty |
|
|
|
freeVars Type{} = mempty |
|
|
|
freeVars Typeω{} = mempty |
|
|
|
freeVars I{} = mempty |
|
|
|
freeVars I0{} = mempty |
|
|
|
freeVars I1{} = mempty |
|
|
|
freeVars (Sigma n x y) = Set.union (freeVars x) (n `Set.delete` freeVars y) |
|
|
|
freeVars (Pair x y) = Set.unions $ map freeVars [x, y] |
|
|
|
freeVars (Proj1 x) = Set.unions $ map freeVars [x] |
|
|
|
freeVars (Proj2 x) = Set.unions $ map freeVars [x] |
|
|
|
freeVars (IAnd x y) = Set.unions $ map freeVars [x, y] |
|
|
|
freeVars (IOr x y) = Set.unions $ map freeVars [x, y] |
|
|
|
freeVars (INot x) = Set.unions $ map freeVars [x] |
|
|
|
freeVars (PathP x y z) = Set.unions $ map freeVars [x, y, z] |
|
|
|
freeVars (IElim x y z a b) = Set.unions $ map freeVars [x, y, z, a, b] |
|
|
|
freeVars (PathIntro x y z a) = Set.unions $ map freeVars [x, y, z, a] |
|
|
|
freeVars (IsOne a) = Set.unions $ map freeVars [a] |
|
|
|
freeVars (IsOne1 a) = Set.unions $ map freeVars [a] |
|
|
|
freeVars (IsOne2 a) = Set.unions $ map freeVars [a] |
|
|
|
freeVars ItIsOne{} = mempty |
|
|
|
freeVars (Partial x y) = Set.unions $ map freeVars [x, y] |
|
|
|
freeVars (PartialP x y) = Set.unions $ map freeVars [x, y] |
|
|
|
freeVars (System fs) = foldr (\(x, y) -> Set.union (Set.union (freeVars x) (freeVars y))) mempty (Map.toList fs) |
|
|
|
|
|
|
|
freeVars (Sub x y z) = Set.unions $ map freeVars [x, y, z] |
|
|
|
freeVars (Inc x y z) = Set.unions $ map freeVars [x, y, z] |
|
|
|
freeVars (Ouc x y z a) = Set.unions $ map freeVars [x, y, z, a] |
|
|
|
freeVars (Comp x y z a) = Set.unions $ map freeVars [x, y, z, a] |
|
|
|
freeVars (GlueTy x y z a) = Set.unions $ map freeVars [x, y, z, a] |
|
|
|
freeVars (Glue x y z a b c) = Set.unions $ map freeVars [x, y, z, a, b, c] |
|
|
|
freeVars (Unglue x y z a c) = Set.unions $ map freeVars [x, y, z, a, c] |
|
|
|
freeVars Bool{} = mempty |
|
|
|
freeVars Tt{} = mempty |
|
|
|
freeVars Ff{} = mempty |
|
|
|
freeVars (If x y z a) = Set.unions $ map freeVars [x, y, z, a] |