I got an inductive type like
Inductive foo (K:Type) : Type :=
| Foo : foo K.
How can I extract this from Coq?
I'm trying to extract to haskell with
(* Assuming there's a haskell type [foo] with constructor [Foo] *)
Extract Inductive foo "K" => "foo" [ "Foo" ].
(* Error at: ↑↑↑ *)
But that gave error:
Syntax error: '=>' expected after [reference] (in [command]).
For constants taking arguments we could do like:
Definition bar (A:Type) := id A.
Extract Constant bar "a" => "Bar a".
(* Assuming there's a haskell type [Bar] *)
Is there a similar way for inductive types taking arguments?
To extract foo
, it suffices to do Require Import Extraction. Extraction foo.
If you want the language to be Haskell, here is a minimal example with some renaming first (because in Haskell datatypes start with capital letters):
Require Import Extraction.
Inductive Foo (K : Type) : Set :=
| FooC : Foo K.
Definition test {K} (x : Foo K) : Foo K := FooC K.
Extraction Language Haskell.
Extraction Foo.
(deleted)
I thought I had it, but I think I'll need a closer look. So I deleted the earlier message.
Last updated: Oct 13 2024 at 01:02 UTC