我最近一直在學習Idris,並決定嘗試編寫一個簡單的張量庫。我從定義類型開始。 data Tensor : Vect n Nat -> Type -> Type
Scalar : a -> Tensor [] a
Dimension : Vect n (Tensor d a) -> Tensor (n::d) a
正如你所看到的,類型Tensor由Nat的Vect A S描
我是伊德里斯的新手。我需要創建一個描述有界數字的數據。所以我做了這樣的數據與這樣一個構造函數: data BoundedDouble : (a, b : Double) -> Type where
MkBoundedDouble : (x : Double) ->
{auto p : a <= x && x <= b = True} ->
Bounde
鑑於這些2和類型: data Foo = A Int | B String
data Bar = C Int | D String
我想定義返回Either (Foo or Bar) String功能。 所以,我試圖使: data Higher = Foo | Bar 但它無法編譯: *ADT> :r
Type checking ./ADT.idr
ADT.idr:3:6:Main.Fo
我想實現一個簡單的代數結構層次結構使用Idris接口。代碼如下: module AlgebraicStructures
-- definition of some algebraic structures in terms of type classes
%access public export
Associative : {a : Type} -> (a -> a -> a) ->
我正在通過Terry Tao的真實分析教科書,它從自然數中構建了基礎數學。通過儘可能多的證明形式,我希望熟悉Idris和依賴類型。 我已經定義了以下數據類型: data GE: Nat -> Nat -> Type where
Ge : (n: Nat) -> (m: Nat) -> GE n (n + m)
代表主張一個自然數大於或等於另一個。 我目前正在努力證明這種關係的反思,即