List 如何在Idris REPL中创建空列表?

List 如何在Idris REPL中创建空列表?,list,read-eval-print-loop,typechecking,idris,dependent-type,List,Read Eval Print Loop,Typechecking,Idris,Dependent Type,我想在REPL中创建myEmptyList和myNonemptyList。但是,Idris报告了myEmptyList的类型不匹配错误。为什么? 不匹配的原因是:let myEmptyList:List Integer=[]未定义myEmptyList,它仅将其类型声明为List Integer=[],这是一种相等类型,它的类型不正确,因为[]和List Integer具有不同的类型 您可以如下定义myEmptyList::让myEmptyList:List Integer;myEmptyLis

我想在REPL中创建myEmptyList和myNonemptyList。但是,Idris报告了myEmptyList的类型不匹配错误。为什么?

不匹配的原因是:let myEmptyList:List Integer=[]未定义myEmptyList,它仅将其类型声明为List Integer=[],这是一种相等类型,它的类型不正确,因为[]和List Integer具有不同的类型


您可以如下定义myEmptyList::让myEmptyList:List Integer;myEmptyList=[],或者:让myEmptyList=列表整数[]。

但是为什么列表整数=[42]要编译?一个bug。Idris似乎接受这一点作为列表的定义,并忽略了整数。您可以使用:let给出一个没有定义的类型,例如:let x:Int。由于x=y是一个类型,因此存在歧义-可以将其解析为列表整数=[]类型或赋值。由于存在歧义,因此会首先尝试将其解析为赋值,然后在赋值失败时解析类型。分配失败,因此它尝试将其作为类型进行解析,这也失败了。我想应该更清楚地报告这种模糊性。尝试编辑:没有意识到“回车”已经发布,我还没有考虑完。很抱歉Grrr@EdwinBrady但是关于:让List Integer=[42]呢?它似乎分配给List而忽略Integer,这肯定不是预期的行为吗?类似地:例如,让foo List Integer=10。@AndrásKovács嗯,我甚至不知道那个人想做什么。我将在新版本中更精确地定义这种行为。
     ____    __     _                                          
    /  _/___/ /____(_)____                                     
    / // __  / ___/ / ___/     Version 1.3.0
  _/ // /_/ / /  / (__  )      http://www.idris-lang.org/      
 /___/\__,_/_/  /_/____/       Type :? for help               

Idris is free software with ABSOLUTELY NO WARRANTY.            
For details type :warranty.
Idris> :let myEmptyList : List Integer = []
(input):1:33: When checking type of myEmptyList:
When checking argument y to type constructor =:
        Type mismatch between
                List elem (Type of [])
        and
                Type (Expected type)
(input):1:18:No type declaration for myEmptyList
Idris> :let myNonemptyList : List Integer = [42]