My favorites | Sign in
Project Logo
             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import "LangPrelude.prg"

prop Free :: Tag ~> Row Tag * ~> * where
Klar :: Free t {}r
Mehr :: DiffLabel t t' -> Free t r -> Free t {t'=a;r}r
deriving List(f)

notMentionedIn :: Label a -> Record sh -> Maybe (Free a sh)
notMentionedIn l {} = Just $ Klar
notMentionedIn l {m=v; r} = do
diff <- case sameLabel l m of
R x -> Just x
_ -> Nothing
r' <- notMentionedIn l r
return $ Mehr diff r'
where monad maybeM

Just test1 = `a `notMentionedIn` {`g=7, `h='a'}

##test "`a occurs in head position"
Just test2 = `a `notMentionedIn` {`g=7, `a='a'}

##test "`a occurs in second position"
Just test3 = `a `notMentionedIn` {`a=7, `b='b'}


data Environment :: Row Tag * ~> * where
Empty :: Environment {}r
Extend :: Free t s => Label t -> a -> Environment s -> Environment {t=a;s}r
deriving Record(e)

verifyEnv :: Record sh -> Maybe (Environment sh)
verifyEnv {} = Just {}e
verifyEnv {l=v; r} = do
l' <- l `notMentionedIn` r
r' <- verifyEnv r
return {l=v; r'}e
where monad maybeM

Just test4 = verifyEnv {`g=7, `a='a', `h="hey"}

##test "`g occurs twice"
Just test5 = verifyEnv {`g=7, `a='a', `g="2"}
Show details Hide details

Change log

r233 by ggreif on Jul 31, 2009   Diff
Free is now a prop. This makes the program
to work
Go to: 
Project members, sign in to write a code review

Older revisions

r232 by ggreif on Jul 31, 2009   Diff
adding a theorem like this does not
work either
r230 by ggreif on Jul 31, 2009   Diff
add a FreeEnv variant with static
constraint in Environment (the
included evidence may be useless
anyway...); caveat: does not compile
r229 by ggreif on Jul 31, 2009   Diff
cleanup
All revisions of this file

File info

Size: 1363 bytes, 43 lines

File properties

svn:mergeinfo
Hosted by Google Code