Default implementations in coq’s Modules -
i have interface want implement several times:
module type i. parameter : a. parameter b : b. parameter c : c. end i. (and assume each of a, b , c many definitions).
an implementation be
module imp1 <: i. definition : := bar. definition b : b := foo a. definition c : c := baz b. end i. now turns out many implementations share definition of b (which require a), have different definitions of c.
how can centralize definition of b? preferably without changing i or duplicating lots of definitions thereof?
(i imagine writing module functor bimp expecting a:a kind of parameter, , can import (bimp a).)
you can outsource shared definitions global definition (here outsourced) parameterized on changing parts of module (here a). don't know if there haskell's default implementations.
module type i. parameter : a. parameter b : b. parameter c : c. end i. definition outsourced (a:a) := foo a. module imp1 <: i. definition : := bar. definition b : b := outsourced a. definition c : c := baz b. end imp1. module imp2 <: i. definition : := bar'. definition b : b := outsourced a. definition c : c := baz' b. end imp2. module coq
No comments:
Post a Comment