Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-frontend
Commits
c56da5ff
Commit
c56da5ff
authored
Aug 07, 2014
by
Jan Rasmus Tikovsky
Browse files
Some refactoring + added new tests
parent
8645929f
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Base/TypeSubst.hs
View file @
c56da5ff
...
...
@@ -45,11 +45,11 @@ instance SubstType Type where
subst
sigma
(
TypeArrow
ty1
ty2
)
=
TypeArrow
(
subst
sigma
ty1
)
(
subst
sigma
ty2
)
subst
_
ts
@
(
TypeSkolem
_
)
=
ts
subst
sigma
(
TypeRecord
fs
rv
)
|
isJust
rv
=
case
substVar
sigma
(
fromJust
rv
)
of
TypeVariable
tv
->
TypeRecord
fs'
(
Just
tv
)
ty
->
ty
|
otherwise
=
TypeRecord
fs'
Nothing
subst
sigma
(
TypeRecord
fs
rv
)
=
case
rv
of
Nothing
->
TypeRecord
fs'
Nothing
Just
r'
->
case
substVar
sigma
r'
of
TypeVariable
tv
->
TypeRecord
fs'
(
Just
tv
)
ty
->
ty
where
fs'
=
map
(
\
(
l
,
ty
)
->
(
l
,
subst
sigma
ty
))
fs
instance
SubstType
TypeScheme
where
...
...
@@ -80,19 +80,17 @@ instance SubstType a => SubstType (TopEnv a) where
expandAliasType
::
[
Type
]
->
Type
->
Type
expandAliasType
tys
(
TypeConstructor
tc
tys'
)
=
TypeConstructor
tc
(
map
(
expandAliasType
tys
)
tys'
)
expandAliasType
tys
(
TypeVariable
n
)
expandAliasType
tys
(
TypeVariable
n
)
|
n
>=
0
=
tys
!!
n
|
otherwise
=
TypeVariable
n
expandAliasType
_
(
TypeConstrained
tys
n
)
=
TypeConstrained
tys
n
expandAliasType
tys
(
TypeArrow
ty1
ty2
)
=
TypeArrow
(
expandAliasType
tys
ty1
)
(
expandAliasType
tys
ty2
)
expandAliasType
_
tsk
@
(
TypeSkolem
_
)
=
tsk
expandAliasType
tys
(
TypeRecord
fs
rv
)
|
isJust
rv
=
let
(
TypeVariable
tv
)
=
expandAliasType
tys
$
TypeVariable
$
fromJust
rv
in
TypeRecord
fs'
(
Just
tv
)
|
otherwise
=
TypeRecord
fs'
Nothing
expandAliasType
tys
(
TypeRecord
fs
rv
)
=
case
rv
of
Nothing
->
TypeRecord
fs'
Nothing
Just
r'
->
let
(
TypeVariable
tv
)
=
expandAliasType
tys
$
TypeVariable
r'
in
TypeRecord
fs'
(
Just
tv
)
where
fs'
=
map
(
\
(
l
,
ty
)
->
(
l
,
expandAliasType
tys
ty
))
fs
normalize
::
Type
->
Type
...
...
src/Transformations/Desugar.hs
View file @
c56da5ff
...
...
@@ -36,7 +36,7 @@
- let expressions, and
- 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 declaration itself nor partial applications of newtype
constructors are changed (It were possible to replace partial
...
...
@@ -44,7 +44,7 @@
However, our solution yields a more accurate output when the result
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
* 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
Supports
Markdown
0%
Try again
or
attach a new 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