Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
curry
curry-frontend
Commits
2b3d21df
Commit
2b3d21df
authored
Aug 07, 2014
by
Jan Rasmus Tikovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Type synonyms in typed expressions are now desugared - fixes #921
parent
41f56b93
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
5 deletions
+33
-5
CHANGELOG.md
CHANGELOG.md
+2
-0
src/Transformations/Desugar.hs
src/Transformations/Desugar.hs
+25
-3
test/TypedExpr.curry
test/TypedExpr.curry
+6
-2
No files found.
CHANGELOG.md
View file @
2b3d21df
...
...
@@ -4,6 +4,8 @@ Change log for curry-frontend
Under development
=================
*
Type synonyms in typed expressions are now desugared - fixes #921
*
Declaration of operator precedence is now optional in infix operator
declarations
...
...
src/Transformations/Desugar.hs
View file @
2b3d21df
...
...
@@ -76,9 +76,10 @@ import Curry.Base.Position hiding (first)
import
Curry.Syntax
import
Base.Expr
import
Base.CurryTypes
(
fromType
)
import
Base.CurryTypes
(
toType
,
fromType
)
import
Base.Messages
(
internalError
)
import
Base.Types
import
Base.TypeSubst
(
expandAliasType
)
import
Base.Typing
import
Base.Utils
(
mapAccumM
,
concatMapM
)
...
...
@@ -425,7 +426,7 @@ dsExpr _ var@(Variable v)
|
otherwise
=
return
var
dsExpr
_
c
@
(
Constructor
_
)
=
return
c
dsExpr
p
(
Paren
e
)
=
dsExpr
p
e
dsExpr
p
(
Typed
e
ty
)
=
f
li
p
Typed
ty
`
liftM
`
dsExpr
p
e
dsExpr
p
(
Typed
e
ty
)
=
li
ftM2
Typed
(
dsExpr
p
e
)
(
dsTypeExpr
ty
)
dsExpr
p
(
Tuple
pos
es
)
=
apply
(
Constructor
$
tupleConstr
es
)
`
liftM
`
mapM
(
dsExpr
p
)
es
where
tupleConstr
es1
=
addRef
pos
$
if
null
es1
then
qUnitId
else
qTupleId
(
length
es1
)
...
...
@@ -519,6 +520,27 @@ dsExpr p (RecordUpdate fs rexpr)
r
<-
recordFromField
(
fieldLabel
(
head
fs
))
dsRecordUpdate
p
r
rexpr
(
map
field2Tuple
fs
)
dsTypeExpr
::
TypeExpr
->
DsM
TypeExpr
dsTypeExpr
ty
=
do
tcEnv
<-
getTyConsEnv
let
expType
=
expandType
tcEnv
(
toType
[]
ty
)
return
$
fromType
expType
expandType
::
TCEnv
->
Type
->
Type
expandType
tcEnv
(
TypeConstructor
tc
tys
)
=
case
qualLookupTC
tc
tcEnv
of
[
DataType
tc'
_
_
]
->
TypeConstructor
tc'
tys'
[
RenamingType
tc'
_
_
]
->
TypeConstructor
tc'
tys'
[
AliasType
_
_
ty
]
->
expandAliasType
tys'
ty
_
->
internalError
$
"Desugar.expandType "
++
show
tc
where
tys'
=
map
(
expandType
tcEnv
)
tys
expandType
_
tv
@
(
TypeVariable
_
)
=
tv
expandType
_
tc
@
(
TypeConstrained
_
_
)
=
tc
expandType
tcEnv
(
TypeArrow
ty1
ty2
)
=
TypeArrow
(
expandType
tcEnv
ty1
)
(
expandType
tcEnv
ty2
)
expandType
_
ts
@
(
TypeSkolem
_
)
=
ts
expandType
tcEnv
(
TypeRecord
fs
rv
)
=
TypeRecord
(
map
(
\
(
l
,
ty
)
->
(
l
,
expandType
tcEnv
ty
))
fs
)
rv
-- If an alternative in a case expression has boolean guards and all of
-- these guards return 'False', the enclosing case expression does
-- not fail but continues to match the remaining alternatives against the
...
...
test/TypedExpr.curry
View file @
2b3d21df
s :: String
s = "hallo" :: String
test1 :: String
test1 = "hallo" :: String
test2 = ["hallo","welt"] :: [String]
test3 = (False, test2) :: (Bool, [String])
\ No newline at end of file
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