[isabelle-dev] [isabelle] Imperative_HOL: code generator setup for Haskell
Florian Haftmann
florian.haftmann at informatik.tu-muenchen.de
Thu Oct 16 13:11:45 CEST 2014
Hi Christian,
> 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)
>
> and
>
> (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
types also.
b) I am uncertain whether the whole state/st cruft is really necessary.
Cheers,
Florian
--
PGP available:
http://home.informatik.tu-muenchen.de/haftmann/pgp/florian_haftmann_at_informatik_tu_muenchen_de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <https://mailman46.in.tum.de/pipermail/isabelle-dev/attachments/20141016/4eb420d6/attachment.sig>
More information about the isabelle-dev
mailing list