Matching patterns to the result of computational type functions in idris

Consider the following snippet:

import Data.List

%default total

x : Elem 1 [1, 2]
x = Here

type : Type
type = Elem 1 [1, 2]

y : type
y = Here

This gives an error:

When checking the right side of y: Type mismatch between Elem x (x :: xs) (Type here) and iType (expected type)

Type yupon request:

type : Type
-----------
y : type

Is it possible to force typeevaluations during or before type assignment y, so that type yis equal Elem 1 [1, 2]?

My use case is that I want to be able to define common predicates that return the correct conditions of a sentence for evidence, for example:

subset : List a -> List a -> Type
subset xs ys = (e : a) -> Elem e xs -> Elem e ys

thm_filter_subset : subset (filter p xs) xs
+4
source share
1 answer

, , , "" . "type" , ( , Idris), (Main, here).

, "" , . , , , . , ( ).

+6
source

Source: https://habr.com/ru/post/1611670/


All Articles