reorganized examples directory
[coq-hetmet.git] / examples / ImmutableHeap.hs
1 {-# OPTIONS_GHC -XModalTypes -XScopedTypeVariables -ddump-types -XNoMonoPatBinds #-}
2 module ImmutableHeap
3 where
4 import IsomorphismForCodeTypes
5 import Prelude hiding ( id, (.) )
6
7
8 class GuestLanguageHeap c where
9   alloc  :: <[ (Integer,Integer) ->  Integer      ]>@c
10   lookup :: <[ Integer       -> (Integer,Integer) ]>@c
11
12 --
13 -- Here's nice example of Sheard's observation that it's often easier
14 -- to write two-stage programs by applying "back" to some function rather than
15 -- writing the final result directly
16 --
17 onetwocycle = back onetwocycle'
18  where
19   onetwocycle' xy = <[ let (x,y) = ~~xy 
20                        in let x' = ~~alloc (1,x)
21                        in let y' = ~~alloc (2,y)
22                        in (x',y')
23                      ]>