idris

    4热度

    1回答

    受this blog post和this code的启发我以为我会在Idris中使用它的接口(类型类)尝试一些类别理论。 我定义Category如下,工作正常: interface Category (obj : Type) (hom : obj -> obj -> Type) where id : {a : obj} -> hom a a comp : {a, b, c :

    3热度

    2回答

    我试图实现尽可能多的系统F(多态lambda微积分),因为我可以在伊德里斯。现在我面对,我想用一个例子来说明一个问题: data Foo = Bar Nat Eq Foo where (Bar _) == (Bar _) = True data Baz: Foo -> Type where Quux: (n: Nat) -> Baz (Bar n) Eq (Baz f) where

    0热度

    1回答

    我想证明一些简单的事情与idris,但我失败悲惨。这里是我的代码 module MyReverse %hide reverse %default total reverse : List a -> List a reverse [] = [] reverse (x :: xs) = reverse xs ++ [x] listEmptyAppend : (l : List a) -

    1热度

    1回答

    我试图写一个函数 roundedSqrt : Nat -> Nat roundedSqrt = abs . round . sqrt . fromIntegral 是否有功能 round: Double -> Int abs : Int -> Nat 或类似的东西在伊德里斯? 编辑: floor : Double -> Int ceiling : Double -> Int 都希

    4热度

    1回答

    Idris标准库(或第三方库)中是否有一个模块允许其他程序执行?我在考虑Python的模块subprocess和Haskell的System.Process。 理想情况下,我想以编程方式与进程交互(写入其标准输入,从标准输出读取等)。

    4热度

    1回答

    在idris中,有一个名为UniqueType的宇宙,其中只能使用一次的类型的值。据我所知,它可以用来编写高性能的代码。 但这一个值只能使用一次的事实,通常是太有限的,所以有一种方法来借用一个值,而不是消耗它的: data Borrowed : UniqueType -> BorrowedType where ... 的Borrowed数据类型被定义为上述伊德里斯。它为什么不简单地返回Type

    5热度

    2回答

    使用Church编码,可以在不使用内置ADT系统的情况下表示任何任意代数数据类型。例如,Nat可以表示(在伊德里斯例如)为: -- Original type data Nat : Type where natSucc : Nat -> Nat natZero : Nat -- Lambda encoded representation Nat : Type Na

    4热度

    1回答

    可以说,我想定义斐波那契函数如下功能: fibo : Int -> Int fibo 1 = 1 fibo 2 = 2 fibo n = fibo (n-1) + fibo (n-2) 此功能显然不能,因为它的不确定低于1的整数总量,所以我需要限制输入论点莫名其妙.. 我试着玩弄定义一个新的数据类型MyInt。沿线的东西: -- bottom is the lower limit da

    0热度

    2回答

    当用下面的代码提交: module TotalityOrWhat %default total data Instruction = Jump Nat | Return Char | Error parse : List Char -> Instruction parse ('j' :: '1' :: _) = Jump 1 parse ('j' :: '2' :: _) = Ju

    2热度

    1回答

    我与伊德里斯最近很多实验,并与下面的“一组类型级别定义”上来: mutual data Set : Type -> Type where Empty : Set a Insert : (x : a) -> (xs : Set a) -> Not (Elem x xs) -> Set a data Elem : (x : a) -> Set a -> Typ