seunguklee / learning-snupl Goto Github PK
View Code? Open in Web Editor NEWLanguage interpreters and type systems implementation from 4190.310 PL homeworks and lecture notes.
License: MIT License
Language interpreters and type systems implementation from 4190.310 PL homeworks and lecture notes.
License: MIT License
let rec f = fn x =>
f (malloc x); f (write "1"); x
in
((f 1) = (f f 1), f f "1")
end
Expected: (bool , string)
Actual: Type Checking Failed
let rec f = fn x =>
(f x) = (f x); malloc (f x); write (f x); x
in
let val x = "const" in f f x end
end
Expected: string
Actual: Type Checking Failed
Test 16 and Test 20 failed
let val print = fn x =>
(write x; true)
in
(print 1, (print (fn x => x), print true))
end
Expected : "Type Checking Failed"
Actual : (bool , (bool , bool))
let val bar = fn x => fn y =>
if x = y then
write x
else
write y
in
let val i = 1
val s = "hello world"
val b = true
val l = malloc 10
in
(bar i 2, bar s "bye world");
(fn z => (z, bar (malloc "aa") (malloc "bb"))) (bar b false)
end
end
Expected : "Type Checking Failed"
Actual : (bool , loc (string))
unify
함수에 pattern matching 에서 다음과 같이 작성하면 문제 없지만:
let rec unify : typ * typ -> Subst.t =
...
fun (given, expected) ->
match (given, expected) with
| ...
| TComparableVar a, t when not (occurs a t) -> ...
| t, TComparableVar a when not (occurs a t) -> ...
| TWritableVar a, t when not (occurs a t) -> ...
| t, TWritableVar a when not (occurs a t) -> ...
다음과 같이 순서가 바뀌어 작성하면 Test 17, 27, 29 가 실패:
let rec unify : typ * typ -> Subst.t =
...
fun (given, expected) ->
match (given, expected) with
| ...
(* Problem *)
| TWritableVar a, t when not (occurs a t) -> ...
| t, TWritableVar a when not (occurs a t) -> ...
| TComparableVar a, t when not (occurs a t) -> ...
| t, TComparableVar a when not (occurs a t) -> ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.