Skip to content

Commit

Permalink
Correct the De Bruijn indices when inferring (and printing) the types…
Browse files Browse the repository at this point in the history
… and values of partially-applied 'mu' combinators
  • Loading branch information
Marc Coiffier committed Apr 30, 2019
1 parent 597d6d6 commit 677b5fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion capricon/capricon.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- see http://haskell.org/cabal/users-guide/

name: capricon
version: 0.13.1.1
version: 0.13.1.2
-- synopsis:
-- description:
license: GPL-3
Expand Down
2 changes: 1 addition & 1 deletion capricon/exe/CaPriCon_Engine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ runWordsState ws st = ($st) $ from (stateT.concatT) $^ do
runWithFS :: JS.JSString -> FSIO a -> JS.CIO a
runWithFS fsname (FSIO r) = newFS fsname >>= r^..readerT

hasteDict = cocDict ("0.13.1.1-js" :: String) getString getBytes setString setBytes
hasteDict = cocDict ("0.13.1.2-js" :: String) getString getBytes setString setBytes

main :: IO ()
main = do
Expand Down
12 changes: 6 additions & 6 deletions capricon/src/Data/CaPriCon.hs
Original file line number Diff line number Diff line change
Expand Up @@ -483,16 +483,16 @@ showNode' dir = go 0
[DocSpace,DocAssoc x' (go 0 env' tx)] + bind_tail ((x',tx):env') e
where x' = fresh (map fst env') x
bind_tail env' x = [bind_sep t,DocSpace,go 0 env' x]
go d env (Cons a) = showA d a
where showA _ (Ap h xs) =
go d env (Cons a) = showA d env a
where showA _ envA (Ap h xs) =
let ni = case h of
Sym i -> DocVarName $ case drop i env of
Sym i -> DocVarName $ case drop i envA of
(h',_):_ -> h'
_ -> "#"+fromString (show i)
Mu _ _ a' -> DocMu (showA 0 a')
Mu envD _ a' -> DocMu (showA 0 (map (\(x,tx,_) -> (x,tx)) envD + envA) a')
Axiom _ ax -> DocText (fromString $ show ax)
lvl = if empty xs then 1000 else 1
in par lvl d $ DocSeq $ intercalate [DocSpace] $ map pure (ni:map (go 2 env) xs)
in par lvl d $ DocSeq $ intercalate [DocSpace] $ map pure (ni:map (go 2 envA) xs)

toPat d env x
| (pats,(_,k)):_ <- findPattern dir x =
Expand Down Expand Up @@ -534,7 +534,7 @@ type_of = yb maybeT . go
go' (Ap (Mu env _ a') subs) = do
ta <- local (map (\(x,tx,_) -> (x,tx)) env +) (go' a')
preret <- maybeT $^ mu_type $ foldl' (\e (x,tx,_) -> Bind Prod x tx e) ta env
rec_subst subs (subst (Cons a') preret)
rec_subst subs (subst (foldl' (\e (x,tx,_) -> Bind Lambda x tx e) (Cons a') env) preret)
go' (Ap (Axiom t _) subs) = rec_subst subs t

rec_subst (y:t) (Bind Prod _ tx e) = do
Expand Down

0 comments on commit 677b5fb

Please sign in to comment.