[isabelle-dev] [isabelle] Imperative_HOL: code generator setup for Haskell
florian.haftmann at informatik.tu-muenchen.de
Thu Oct 16 13:11:45 CEST 2014
> What I did in the attached theory files is essentially make a copy of
> the Imperative/HOL development using "'a Heap" and adding an additional
> phantom type parameter 's (for state) *everywhere* (i.e., heap monad,
> array type and operations, ref type and operations, ...). Finally there
> is a function "runST :: (unit, 'a) st => 'a" (where "('s, 'a) st" more
> or less corresponds to the previous "'a Heap") which is code generated
> to Haskell's "runST :: (forall s. ST s a) -> a". It's logical definition
> is "runST c = (case execute c initial_state of Some (x, _) => x)" where
> "initial_state" is "State ST_Heap.empty" for the new datatypes
> 's state = State (heap : heap) (*heap is almost the same as the
> original heap)
> (dead 's, 'a) st = ST (execute : "'s state => ('a * 's state) option")
thanks for trying that out.
Adding the formal state type everywhere seems indeed a suitable solution.
I do not have time at the moment to study the sources in detail, but I
am asking myself two questions:
a) Can the same development still be used to generate code for ML and
Scala? I guess yes (except runST of course). The only thing to add is
maybe a small adaptation layer which adds arrays and refs with phantom
b) I am uncertain whether the whole state/st cruft is really necessary.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 181 bytes
Desc: OpenPGP digital signature
More information about the isabelle-dev