meta-logic / sml-to-coq

A tool that translates SML code to Coq
GNU General Public License v3.0
6 stars 0 forks source link

Value declaration with patterns on the left #9

Open gisellemnr opened 3 years ago

gisellemnr commented 3 years ago

Currently we need to unpack all variables on the left of an SML declaration and create one Coq definition for each, duplicating some code. The SML code val x :: l = [1 ,2 ,3] becomes:

Definition x := match [1; 2; 3] with (x :: l) => x
                                   | _ => patternFailure
                end .
Definition l := match [1; 2; 3] with (x :: l) => l
                                   | _ => patternFailure
                end .

To avoid this duplication, we could use tuples:

Definition t := match [1; 2; 3] with (x :: l) => x
                                   | _ => patternFailure
                end .
Definition x := fst t.
Definition l := snd t.

Issues to solve when implementing this solution: