我目前正在尝试从Idris删除所有未使用的索引 程序-但是在一种情况下,Idris编译器会看到索引 可达。我试图在下面复制行为 最小的例子:
module Main
%access public export
-- CUSTOM VECTOR TYPES
data VectA : Nat -> Type -> Type where
VNilA : VectA Z a
VConsA : a -> VectA len a -> VectA (S len) a
data VectB : Nat -> Type -> Type where
VNilB : VectB Z a
VConsB : a -> VectB len a -> VectB (S len) a
-- THE FOLLOWING FUNCTIONS ARE USED TO CREATE A
-- CUSTOM VECTOR WHERE THE SIZE IS UNKNOWN
fromList : (l : List a) -> VectA (length l) a
fromList [] = VNilA
fromList (x::xs) = VConsA x (fromList xs)
createList : String -> List Int
createList "42" = [42, 42, 42]
createList _ = [1, 2, 3, 4]
-- SOME NESTED TRANSFORMATION FUNCTIONS ON VECT
transformVectA : VectA n a -> Maybe (VectB n a)
transformVectA VNilA = Just VNilB
transformVectA (VConsA v vs) =
case transformVectA vs of
Just vs' => Just $ VConsB v vs'
Nothing => Nothing
transformVectB : VectA m a -> VectB n a -> Maybe (VectB n a)
transformVectB VNilA ws = Just ws
transformVectB (VConsA v vs) ws = transformVectB vs ws
transformVect : VectA n a -> VectA m a -> Maybe (VectB n a)
transformVect VNilA VNilB = Nothing
transformVect VNilA VNilA = Nothing
transformVect vs VNilA = Nothing
transformVect (VConsA v vs) xs =
case transformVectA (VConsA v vs) of
Nothing => Nothing
Just vs' => transformVectB xs vs'
main : IO ()
main = do
(testArg :: _) <- getArgs
ls <- pure $ createList testArg
va <- pure $ fromList ls
vb <- pure $ transformVect va va
putStrLn "OK"
通过运行以下命令进行编译时:
idris Erasure.idr -o Erasure --warnreach
...显示以下警告:
Main.transformVect: inaccessible arguments reachable:
n (no more information available)
m (no more information available)
我在阅读垃圾箱时也遇到麻烦 使用其他选项进行编译:
-转储cases.txt
为什么出现这些警告? 是否有任何有关Idris处理方式的信息 除“使用情况擦除分析”一章中的“擦除” 教程?