Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jeanne-Marie Musca
gg-proto
Commits
4f153095
Commit
4f153095
authored
Mar 10, 2016
by
matthew-eads
Browse files
support for maybe types
parent
ed85b0b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Imp.ast
View file @
4f153095
...
...
@@ -10,7 +10,7 @@ data Exp = SET ID Exp
| IF SimpleExp Exp Exp
| WHILE SimpleExp Exp
| BEGIN (List1 Exp)
| TUPY (Exp, Exp)
| TUPY (Exp, Exp)
(Maybe Potato)
| LET [(String, Exp)]
data BinOp = Plus SimpleExp SimpleExp
...
...
src/AST.hs
View file @
4f153095
...
...
@@ -59,9 +59,18 @@ stypeToString :: StrictType -> (String, String)
stypeToString
(
_
,
(
ConT
n
))
=
(
showName
n
,
""
)
stypeToString
(
_
,
(
AppT
ListT
t
))
=
let
(
s
,
rs
)
=
(
stypeToString
(
IsStrict
,
t
))
in
(
s
++
"*"
,
(
rs
++
"
\n\n
"
++
makeMultiRules
(
AppT
(
ConT
list0
)
t
)
s
))
stypeToString
(
_
,
(
AppT
(
ConT
n
)
t
))
=
let
(
s
,
rs
)
=
(
stypeToString
(
IsStrict
,
t
))
c
=
if
n
==
list0
then
"*"
else
"+"
in
(
s
++
c
,
(
rs
++
"
\n\n
"
++
makeMultiRules
(
AppT
(
ConT
n
)
t
)
s
))
stypeToString
(
_
,
(
AppT
(
ConT
n
)
t
))
=
if
n
==
list0
||
n
==
list1
then
let
(
s
,
rs
)
=
(
stypeToString
(
IsStrict
,
t
))
c
=
if
n
==
list0
then
"*"
else
"+"
in
(
s
++
c
,
(
rs
++
"
\n\n
"
++
makeMultiRules
(
AppT
(
ConT
n
)
t
)
s
))
else
if
n
==
(
mkName
"Maybe"
)
then
let
(
s
,
rs
)
=
(
stypeToString
(
IsStrict
,
t
))
in
((
"Maybe"
++
s
),
rs
++
(
"
\n\n
Maybe"
++
s
++
": "
++
s
++
"
\t
{Just $1}
\n
"
++
(
makeTab
(
"maybe"
++
s
))
++
"|
\t
{Nothing}"
))
else
(
""
,
""
)
stypeToString
(
_
,
(
AppT
t1
t2
))
=
let
ts
=
flattenTuple
t1
t2
ts'
=
map
(
stypeToString
.
(
\
x
->
(
IsStrict
,
x
)))
ts
(
s
,
rs
)
=
((
foldr
(
\
(
x
,
y
)
a
->
(
fixMultis
x
)
++
"
\\
"
++
a
)
""
ts'
),
...
...
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