Why can't I use `app` with` fold_right` in Coq?

I get a type error in the last line of the following program:

Require Import List.
Import ListNotations.

(* This computes to 10 *)
Compute (fold_right plus 0 [1;2;3;4]).

(* I want this to compute to [5;6;7;8] but it gives a type error instead *)
Compute (fold_right app [] [[5;6]; [7;8]]).

This is the error I get:

Error:
The term "app" has type "forall A : Type, list A -> list A -> list A" while it is expected to have type
 "Type -> ?A -> ?A" (cannot instantiate "?A" because "A" is not in its scope).

I do not understand why I am getting this error. What is different from appand plus? Is this connected with the fact that it appis polymorphic, but plusis a monomorphic function nat -> nat -> nat?

In case that matters, my Coq version is 8.5.

+4
source share
1 answer

, : - app, . , Coq - , . , , -, , , app. :

1- Force Coq - , fold_right (@app _) [] [[5; 6]; [7; 8]].

2- , : Arguments app {_} _ _.. , , . .

+6

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


All Articles