在下面的代碼中,爲什麼@{myOrd}放置在他的參數之前而不是之後? [myOrd] Ord Nat where
compare Z (s n) = GT
compare (S n) Z = LT
compare (z z = EQ
compare (S x) (S y) = compare @{myOrd} x y
有什麼優點和缺點?
試圖解決有關矩陣乘法的練習Type driven development with Idris已經導致我成爲一個煩人的問題。 到目前爲止,我已經結束了定義這樣一組輔助功能: morexs : (n : Nat) -> Vect m a -> Vect n (Vect m a)
morexs n xs = replicate n xs
mult_cols : Num a => Vect m (
我一直無法說服我的功能是完整的伊德里斯總體檢查。以下是我遇到的問題的簡單示例版本。假設我們有以下形式的一個非常簡單的表達式類型: data SimpleType = Prop | Fn SimpleType SimpleType
data Expr : SimpleType -> Type where
Var : String -> Expr type
Lam : Stri
在伊德里斯,我可以通過添加相同大小的兩個向量: *MatrixMath> :l MatrixMath.idr
Type checking ./MatrixMath.idr
我可以: module MatrixMath
import Data.Vect
addHelper : (Num n) => Vect k n -> Vect k n -> Vect k n
addHelper
下面是本教程中,稍加修改簡單的例子: data Vect : Nat -> (b:Type) -> Type where
Nil : Vect Z a
(::) : a -> Vect k a -> Vect (S k) a
data Elem : a -> Vect n a -> Type where
Here : {x:a} -> {xs:Vect n a}