Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ICFP contest 2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nathaniel Mattsson
ICFP contest 2024
Commits
b43674ce
Commit
b43674ce
authored
8 months ago
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Fix serializer, + compilation.
parent
cae6987a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Eval.hs
+2
-0
2 additions, 0 deletions
Eval.hs
Serialize.hs
+32
-6
32 additions, 6 deletions
Serialize.hs
main.hs
+2
-0
2 additions, 0 deletions
main.hs
serialize.hs
+0
-34
0 additions, 34 deletions
serialize.hs
with
36 additions
and
40 deletions
Eval.hs
+
2
−
0
View file @
b43674ce
{-# Language ImportQualifiedPost #-}
module
Eval
where
module
Eval
where
import
Data.Map.Strict
qualified
as
Map
import
Data.Map.Strict
qualified
as
Map
...
...
This diff is collapsed.
Click to expand it.
Serialize.hs
+
32
−
6
View file @
b43674ce
module
Serialize
where
module
Serialize
where
import
Data.Char
(
ord
,
chr
)
import
Expression
import
Expression
serialize
::
Expression
->
String
encodeNumber
::
Integer
->
String
serialize
(
Number
x
)
=
encodeNumber
x
=
[
chr
(
fromInteger
a
+
33
)
|
a
<-
[
mod
(
div
x
(
94
^
b
))
94
|
b
<-
[
y
,
y
-
1
..
0
]]]
chr
.
(
+
33
)
.
fromInteger
<$>
where
y
=
floor
$
logBase
94.0
(
fromInteger
x
)
[(
x
`
div
`
94
^
b
)
`
mod
`
94
|
b
<-
[
digits
,
digits
-
1
..
0
]]
where
digits
=
floor
$
logBase
94
(
fromInteger
x
)
serialize
(
Number
x
)
=
'I'
:
encodeNumber
x
serialize
(
Str
x
)
=
'S'
:
fmap
(
chr
.
(
+
33
)
.
ord
)
x
serialize
(
Boolean
True
)
=
"T"
serialize
(
Boolean
False
)
=
"F"
serialize
(
Variable
x
)
=
'V'
:
(
fmap
(
chr
.
(
+
33
)
.
ord
)
$
encodeNumber
x
)
serialize
(
Lambda
x
y
)
=
"L"
++
fmap
(
chr
.
(
+
33
)
.
ord
)
(
encodeNumber
x
)
++
" "
++
serialize
y
serialize
(
Negate
x
)
=
"U- "
++
serialize
x
serialize
(
Not
x
)
=
"U! "
++
serialize
x
serialize
(
StringToInt
x
)
=
"U# "
++
serialize
x
serialize
(
IntToString
x
)
=
"U$ "
++
serialize
x
serialize
(
Add
x
y
)
=
"B+ "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Sub
x
y
)
=
"B- "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Mul
x
y
)
=
"B* "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Div
x
y
)
=
"B/ "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Mod
x
y
)
=
"B% "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Gt
x
y
)
=
"B> "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Lt
x
y
)
=
"B< "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Eq
x
y
)
=
"B= "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Or
x
y
)
=
"B| "
++
serialize
x
++
" "
++
serialize
y
serialize
(
And
x
y
)
=
"B& "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Concat
x
y
)
=
"B++ "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Take
x
y
)
=
"BT "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Drop
x
y
)
=
"BD "
++
serialize
x
++
" "
++
serialize
y
serialize
(
Apply
x
y
)
=
"B$ "
++
serialize
x
++
" "
++
serialize
y
serialize
(
If
x
y
z
)
=
"? "
++
serialize
x
++
" "
++
serialize
y
++
" "
++
serialize
z
This diff is collapsed.
Click to expand it.
main.hs
+
2
−
0
View file @
b43674ce
{-# Language ImportQualifiedPost #-}
import
Data.Map.Strict
qualified
as
Map
import
Data.Map.Strict
qualified
as
Map
import
Text.Parsec
(
parse
)
import
Text.Parsec
(
parse
)
import
Control.Monad.Reader
(
runReader
)
import
Control.Monad.Reader
(
runReader
)
...
...
This diff is collapsed.
Click to expand it.
serialize.hs
deleted
100644 → 0
+
0
−
34
View file @
cae6987a
module
Serialize
where
import
Data.Char
(
ord
,
chr
)
import
Expression
serialize
::
Expression
->
String
serialize
(
Number
x
)
=
'I'
:
[
chr
((
fromInteger
a
)
+
33
)
|
a
<-
[
mod
(
div
x
(
94
^
b
))
94
|
b
<-
[
y
,
y
-
1
..
0
]]]
where
y
=
floor
(
logBase
94.0
(
fromInteger
x
)
)
serialize
(
Str
x
)
=
'S'
:
[
chr
((
ord
a
)
+
33
)
|
a
<-
x
]
serialize
(
Boolean
x
)
=
if
x
then
"T"
else
"F"
serialize
(
Variable
x
)
=
"V"
.
[
chr
(
ord
(
x
)
+
33
)]
serialize
(
Lambda
x
y
)
=
"L"
.
[
chr
(
ord
(
x
)
+
33
)]
.
" "
.
(
serialize
y
)
serialize
(
Negate
x
)
=
"U- "
.
(
serialize
x
)
serialize
(
Not
x
)
=
"U! "
.
(
serialize
x
)
serialize
(
StringToInt
x
)
=
"U# "
.
(
serialize
x
)
serialize
(
IntToString
x
)
=
"U$ "
.
(
serialize
x
)
serialize
(
Add
x
y
)
=
"B+ "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Sub
x
y
)
=
"B- "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Mul
x
y
)
=
"B* "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Div
x
y
)
=
"B/ "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Mod
x
y
)
=
"B% "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Gt
x
y
)
=
"B> "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Lt
x
y
)
=
"B< "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Eq
x
y
)
=
"B= "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Or
x
y
)
=
"B| "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
And
x
y
)
=
"B& "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Concat
x
y
)
=
"B. "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Take
x
y
)
=
"BT "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Drop
x
y
)
=
"BD "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
Apply
x
y
)
=
"B$ "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
serialize
(
If
x
y
z
)
=
"? "
.
(
serialize
x
)
.
" "
.
(
serialize
y
)
.
" "
.
(
serialize
z
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment