Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gilles Coremans
ASTTool
Commits
3e5f5261
Commit
3e5f5261
authored
Apr 28, 2020
by
Gilles Coremans
Browse files
Merge branch 'master' of github.com:martonbognar/ASTTool into genterm
parents
015e2ca1
8b840421
Changes
2
Hide whitespace changes
Inline
Side-by-side
SystemF/SystemFBase.hs
View file @
3e5f5261
...
...
@@ -16,8 +16,8 @@ data Type = TyVar Variable | TyArr Type Type | TyAll Type | TyBase deriving(Show
plus
(
Z
)
h
=
h
plus
h
(
Z
)
=
h
plus
x1
(
STypeVar
x2
)
=
(
STypeVar
(
plus
x1
x2
))
plus
x1
(
STermVar
x2
)
=
(
STermVar
(
plus
x1
x2
))
plus
(
STypeVar
x
1
)
x
2
=
(
STypeVar
(
plus
x1
x2
))
plus
(
STermVar
x
1
)
x
2
=
(
STermVar
(
plus
x1
x2
))
minus
(
Z
)
(
Z
)
=
(
Z
)
minus
(
Z
)
_
=
(
error
"You cannot substract zero with a positive number"
)
...
...
SystemF/SystemFImpl.hs
View file @
3e5f5261
...
...
@@ -21,21 +21,14 @@ isVal (TmTAbs t1) = True
isVal
_
=
False
getTypeFromEnv
::
Env
->
Variable
->
Either
String
Type
getTypeFromEnv
(
ETermVar
(
TyVar
i
)
_
)
Z
=
return
$
TyVar
(
STermVar
i
)
getTypeFromEnv
(
ETermVar
ty
_
)
Z
=
return
ty
getTypeFromEnv
_
Z
=
Left
"wrong or no binding for term"
getTypeFromEnv
(
ETermVar
_
rest
)
(
STermVar
h
)
=
do
t
<-
getTypeFromEnv
rest
h
case
t
of
(
TyVar
i
)
->
return
$
TyVar
(
STermVar
i
)
otherwise
->
return
t
getTypeFromEnv
(
ETypeVar
rest
)
(
STypeVar
h
)
=
do
t
<-
getTypeFromEnv
rest
h
case
t
of
(
TyVar
i
)
->
return
$
TyVar
(
STypeVar
i
)
otherwise
->
return
t
getTypeFromEnv
_
(
STermVar
h
)
=
Left
"wrong term binding"
getTypeFromEnv
_
(
STypeVar
h
)
=
Left
"No variable type"
getTypeFromEnv
e
v
=
go
e
v
Z
where
go
::
Env
->
Variable
->
Variable
->
Either
String
Type
go
(
ETermVar
ty
_
)
Z
shift
=
return
$
typeshiftplus
(
plus
shift
(
STermVar
Z
))
ty
go
_
Z
_
=
Left
"wrong or no binding for term"
go
(
ETermVar
_
rest
)
(
STermVar
h
)
shift
=
go
rest
h
(
plus
shift
(
STermVar
Z
))
go
(
ETypeVar
rest
)
(
STypeVar
h
)
shift
=
go
rest
h
(
plus
shift
(
STypeVar
Z
))
go
_
(
STermVar
h
)
_
=
Left
"wrong term binding"
go
_
(
STypeVar
h
)
_
=
Left
"No variable type"
--evaluation
stepEval
::
Term
->
Maybe
Term
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment