Function 理解部分函数的输出

Function 理解部分函数的输出,function,idris,Function,Idris,给定以下部分功能(对于Nothing输入无输出): REPL显示了以下内容: *Lecture> f $ Just 42 Just 42 : Maybe Int *Lecture> f Nothing f Nothing : Maybe Int f Nothing输出的含义是什么?Idris不会减少涉及调用不匹配模式的部分函数的表达式。换句话说,这只是REPL表示未定义或“底部”值的方式。假设您在可执行文件中进行调用,那么您将得到一个运行时错误 发件人: 尽管[a partial

给定以下部分功能(对于
Nothing
输入无输出):

REPL显示了以下内容:

*Lecture> f $ Just 42
Just 42 : Maybe Int

*Lecture> f Nothing
f Nothing : Maybe Int

f Nothing
输出的含义是什么?

Idris不会减少涉及调用不匹配模式的部分函数的表达式。换句话说,这只是REPL表示未定义或“底部”值的方式。假设您在可执行文件中进行调用,那么您将得到一个运行时错误

发件人:

尽管[a partial function]进行了类型检查和编译,但它不会减少(也就是说,对该函数的求值会导致它发生更改):

*Lecture> f $ Just 42
Just 42 : Maybe Int

*Lecture> f Nothing
f Nothing : Maybe Int
-- Unsafe head example!
unsafeHead : List a -> a
unsafeHead (x::xs) = x

unsafe> the Integer $ unsafeHead [1, 2, 3]
1 : Integer
unsafe> the Integer $ unsafeHead []
unsafeHead [] : Integer