Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Frontull Samuel
alpha
Commits
c6b49c55
Commit
c6b49c55
authored
Jul 27, 2021
by
Frontull Samuel
Browse files
unString vs unChurch
parent
d8515360
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
pcp/pcp.hs
pcp/pcp.hs
+10
-10
No files found.
pcp/pcp.hs
View file @
c6b49c55
...
...
@@ -44,22 +44,22 @@ second = \p -> p (\x -> \y -> y)
-- STRINGS
type
LCStrT
=
forall
a
.
a
->
(
a
->
a
)
->
(
a
->
a
)
->
a
newtype
LCStr
=
LCStr
{
un
Church
::
LCStrT
}
newtype
LCStr
=
LCStr
{
un
String
::
LCStrT
}
empty
::
LCStr
empty
=
LCStr
$
\
x
a
b
->
x
isempty
::
LCStr
->
LCBool
isempty
=
\
s
->
un
Church
s
true
af
af
isempty
=
\
s
->
un
String
s
true
af
af
conc
::
LCStr
->
LCStr
->
LCStr
conc
=
\
y
z
->
LCStr
$
\
x
a
b
->
un
Church
y
(
unChurch
z
x
a
b
)
a
b
conc
=
\
y
z
->
LCStr
$
\
x
a
b
->
un
String
y
(
unString
z
x
a
b
)
a
b
prepa
::
LCStr
->
LCStr
prepa
=
\
s
->
LCStr
$
\
x
a
b
->
a
(
un
Church
s
x
a
b
)
prepa
=
\
s
->
LCStr
$
\
x
a
b
->
a
(
un
String
s
x
a
b
)
prepb
::
LCStr
->
LCStr
prepb
=
\
s
->
LCStr
$
\
x
a
b
->
b
(
un
Church
s
x
a
b
)
prepb
=
\
s
->
LCStr
$
\
x
a
b
->
b
(
un
String
s
x
a
b
)
nexta
::
LCPair
LCStr
->
LCPair
LCStr
nexta
=
\
x
->
pair
(
prepa
(
first
x
))
(
first
x
)
...
...
@@ -68,19 +68,19 @@ nextb :: LCPair LCStr -> LCPair LCStr
nextb
=
\
x
->
pair
(
prepb
(
first
x
))
(
first
x
)
hd_a
::
LCStr
->
LCBool
hd_a
=
\
s
->
un
Church
s
false
at
af
hd_a
=
\
s
->
un
String
s
false
at
af
hd_b
::
LCStr
->
LCBool
hd_b
=
\
s
->
un
Church
s
false
af
at
hd_b
=
\
s
->
un
String
s
false
af
at
hd_eq
::
LCStr
->
LCStr
->
LCBool
hd_eq
=
\
x
y
->
lor
(
land
(
hd_a
x
)
(
hd_a
y
))
(
land
(
hd_b
x
)
(
hd_b
y
))
hd
::
LCStr
->
LCStr
hd
=
\
s
->
LCStr
$
\
x
a
b
->
un
Church
s
x
(
\
y
->
a
x
)
(
\
y
->
b
x
)
hd
=
\
s
->
LCStr
$
\
x
a
b
->
un
String
s
x
(
\
y
->
a
x
)
(
\
y
->
b
x
)
tl
::
LCStr
->
LCStr
tl
=
\
s
->
second
(
un
Church
s
(
pair
empty
empty
)
nexta
nextb
)
tl
=
\
s
->
second
(
un
String
s
(
pair
empty
empty
)
nexta
nextb
)
eq
::
LCStr
->
LCStr
->
LCBool
eq
=
ycomb
(
\
f
x
y
->
...
...
@@ -198,7 +198,7 @@ problem_3 = cons (pair bba b) (cons (pair b ab) (cons (pair a bba) nil))
-- Output functions
lcstr_tostr
::
LCStr
->
String
lcstr_tostr
=
\
s
->
un
Church
s
(
""
)
(
\
a
->
"a"
++
a
)
(
\
b
->
"b"
++
b
)
lcstr_tostr
=
\
s
->
un
String
s
(
""
)
(
\
a
->
"a"
++
a
)
(
\
b
->
"b"
++
b
)
lcbool_tostr
::
LCBool
->
String
lcbool_tostr
=
\
b
->
ite
b
"True"
"False"
...
...
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