Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
curry
curry-frontend
Commits
c56da5ff
Commit
c56da5ff
authored
Aug 07, 2014
by
Jan Rasmus Tikovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some refactoring + added new tests
parent
8645929f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
14 deletions
+17
-14
src/Base/TypeSubst.hs
src/Base/TypeSubst.hs
+10
-12
src/Transformations/Desugar.hs
src/Transformations/Desugar.hs
+2
-2
test/DefaultPrecedence.curry
test/DefaultPrecedence.curry
+3
-0
test/TypedExpr.curry
test/TypedExpr.curry
+2
-0
No files found.
src/Base/TypeSubst.hs
View file @
c56da5ff
...
@@ -45,11 +45,11 @@ instance SubstType Type where
...
@@ -45,11 +45,11 @@ instance SubstType Type where
subst
sigma
(
TypeArrow
ty1
ty2
)
=
subst
sigma
(
TypeArrow
ty1
ty2
)
=
TypeArrow
(
subst
sigma
ty1
)
(
subst
sigma
ty2
)
TypeArrow
(
subst
sigma
ty1
)
(
subst
sigma
ty2
)
subst
_
ts
@
(
TypeSkolem
_
)
=
ts
subst
_
ts
@
(
TypeSkolem
_
)
=
ts
subst
sigma
(
TypeRecord
fs
rv
)
subst
sigma
(
TypeRecord
fs
rv
)
=
case
rv
of
|
isJust
rv
=
case
substVar
sigma
(
fromJust
rv
)
of
Nothing
->
TypeRecord
fs'
Nothing
TypeVariable
tv
->
TypeRecord
fs'
(
Just
tv
)
Just
r'
->
case
substVar
sigma
r'
of
ty
->
ty
TypeVariable
tv
->
TypeRecord
fs'
(
Just
tv
)
|
otherwise
=
TypeRecord
fs'
Nothing
ty
->
ty
where
fs'
=
map
(
\
(
l
,
ty
)
->
(
l
,
subst
sigma
ty
))
fs
where
fs'
=
map
(
\
(
l
,
ty
)
->
(
l
,
subst
sigma
ty
))
fs
instance
SubstType
TypeScheme
where
instance
SubstType
TypeScheme
where
...
@@ -80,19 +80,17 @@ instance SubstType a => SubstType (TopEnv a) where
...
@@ -80,19 +80,17 @@ instance SubstType a => SubstType (TopEnv a) where
expandAliasType
::
[
Type
]
->
Type
->
Type
expandAliasType
::
[
Type
]
->
Type
->
Type
expandAliasType
tys
(
TypeConstructor
tc
tys'
)
=
expandAliasType
tys
(
TypeConstructor
tc
tys'
)
=
TypeConstructor
tc
(
map
(
expandAliasType
tys
)
tys'
)
TypeConstructor
tc
(
map
(
expandAliasType
tys
)
tys'
)
expandAliasType
tys
(
TypeVariable
n
)
expandAliasType
tys
(
TypeVariable
n
)
|
n
>=
0
=
tys
!!
n
|
n
>=
0
=
tys
!!
n
|
otherwise
=
TypeVariable
n
|
otherwise
=
TypeVariable
n
expandAliasType
_
(
TypeConstrained
tys
n
)
=
TypeConstrained
tys
n
expandAliasType
_
(
TypeConstrained
tys
n
)
=
TypeConstrained
tys
n
expandAliasType
tys
(
TypeArrow
ty1
ty2
)
=
expandAliasType
tys
(
TypeArrow
ty1
ty2
)
=
TypeArrow
(
expandAliasType
tys
ty1
)
(
expandAliasType
tys
ty2
)
TypeArrow
(
expandAliasType
tys
ty1
)
(
expandAliasType
tys
ty2
)
expandAliasType
_
tsk
@
(
TypeSkolem
_
)
=
tsk
expandAliasType
_
tsk
@
(
TypeSkolem
_
)
=
tsk
expandAliasType
tys
(
TypeRecord
fs
rv
)
expandAliasType
tys
(
TypeRecord
fs
rv
)
=
case
rv
of
|
isJust
rv
=
Nothing
->
TypeRecord
fs'
Nothing
let
(
TypeVariable
tv
)
=
expandAliasType
tys
$
TypeVariable
$
fromJust
rv
Just
r'
->
let
(
TypeVariable
tv
)
=
expandAliasType
tys
$
TypeVariable
r'
in
TypeRecord
fs'
(
Just
tv
)
in
TypeRecord
fs'
(
Just
tv
)
|
otherwise
=
TypeRecord
fs'
Nothing
where
fs'
=
map
(
\
(
l
,
ty
)
->
(
l
,
expandAliasType
tys
ty
))
fs
where
fs'
=
map
(
\
(
l
,
ty
)
->
(
l
,
expandAliasType
tys
ty
))
fs
normalize
::
Type
->
Type
normalize
::
Type
->
Type
...
...
src/Transformations/Desugar.hs
View file @
c56da5ff
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
- let expressions, and
- let expressions, and
- case expressions.
- case expressions.
* Applications 'N
:
x' in patterns and expressions, where 'N' is a
* Applications 'N
x' in patterns and expressions, where 'N' is a
newtype constructor, are replaced by a 'x'. Note that neither the
newtype constructor, are replaced by a 'x'. Note that neither the
newtype declaration itself nor partial applications of newtype
newtype declaration itself nor partial applications of newtype
constructors are changed (It were possible to replace partial
constructors are changed (It were possible to replace partial
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
However, our solution yields a more accurate output when the result
However, our solution yields a more accurate output when the result
of a computation includes partial applications.).
of a computation includes partial applications.).
* Function patterns are replaced by variables and are integrated
* Function
al
patterns are replaced by variables and are integrated
in a guarded right hand side using the (=:<=) operator
in a guarded right hand side using the (=:<=) operator
* Records, which currently must be declared using the keyword
* Records, which currently must be declared using the keyword
...
...
test/DefaultPrecedence.curry
0 → 100644
View file @
c56da5ff
-- infixr 9 <$>
f <$> x = f x
\ No newline at end of file
test/TypedExpr.curry
0 → 100644
View file @
c56da5ff
s :: String
s = "hallo" :: String
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