我想實現像在伊德里斯功能隊列,但它攜帶在類型元素的數目 - 如Queue ty n m (n+m)其中n是一個Vect n ty元素的數量,m是第二個元素Vect m ty,而(n+m)是總元素。 的問題是,我遇到了問題與操縱這些尺寸爲隱式參數時應用重寫規則: module Queue
import Data.Vect as V
data Queue : Type -> Nat -> Na
我試圖實現Semigroup接口,用於伊德里斯簡單依賴對,取決於對但這並不編譯: Semigroup (n ** Vect n f) where
(<+>) (_ ** xs) (_ ** ys) = (_ ** xs ++ ys)
與錯誤 Type mismatch between
ty
and
Nat
但是這樣編譯: myPair:Type -> Typ
我想編譯Idris中的interface的簡單示例。 interface Foo a where
foo : a -> String
但我不斷收到這種類型檢查錯誤: error: expected: "with",
argument expression,
function right hand side,
implicit function argument,
with p
鑑於從Type-Driven Development with Idris如下: import Data.Vect
data EqNat : (num1 : Nat) -> (num2 : Nat) -> Type where
Same : (num : Nat) -> EqNat num num
sameS : (eq : EqNat k j) -> EqNat
鑑於下面的部分功能(沒有輸出用於Nothing輸入)的理解輸出: f : Maybe Int -> Maybe Int
f (Just 42) = Just 42
的REPL顯示以下內容: *Lecture> f $ Just 42
Just 42 : Maybe Int
*Lecture> f Nothing
f Nothing : Maybe Int
什麼是f Nothing
我玩弄伊德里斯和我碰到一些東西,混淆了我一點點走過來: 以下類型檢查: conc : Vect n a -> Vect m a -> Vect (n+m) a
conc [] ys = ys
conc (x :: xs) ys = x :: (conc xs ys)
但這並不: conc : Vect n a -> Vect m a -> Vect (m+n) a
conc [] ys