-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ranjit Jhala
committed
Jan 7, 2024
1 parent
5511727
commit 896e277
Showing
571 changed files
with
86,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Dr. Kat | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
site: | ||
stack build | ||
stack exec -- homepage rebuild | ||
|
||
upload: | ||
cp -r _site/* docs/ | ||
cd docs/ && git add . && git commit -a -m "update page" && git push origin main | ||
|
||
clean: | ||
rm -rf *.hi *.o .*.swp .*.swo website _site/ _cache/ | ||
|
||
server: | ||
stack exec -- homepage watch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# 130-web | ||
|
||
|
||
Public course materials for [UCSD CSE 130: Winter 2024](https://ucsd-cse130.github.io/wi24/) | ||
|
||
## Install | ||
|
||
You too, can build this webpage locally, like so: | ||
|
||
```bash | ||
git clone [email protected]:ucsd-cse130/wi24.git | ||
cd wi24 | ||
make | ||
``` | ||
|
||
To then update the webpage after editing stuff, do: | ||
|
||
```bash | ||
make upload | ||
``` | ||
|
||
The website will live in `_site/`. | ||
|
||
## Customize | ||
|
||
By editing the parameters in `siteCtx` in `Site.hs` | ||
|
||
## View | ||
|
||
You can view it by running | ||
|
||
```bash | ||
make server | ||
``` | ||
|
||
## Update | ||
|
||
Either do | ||
|
||
```bash | ||
make upload | ||
``` | ||
|
||
or, if you prefer | ||
|
||
```bash | ||
make | ||
cp -r _site/* docs/ | ||
git commit -a -m "update webpage" | ||
git push origin main | ||
``` | ||
|
||
## To build Lecture Versions | ||
|
||
To build the "lecture" version of all the html i.e. *without* | ||
the answers to quizzes and other questions, replace the | ||
following in `Site.hs` | ||
|
||
```haskell | ||
crunchWithCtxCustom "final" postCtx | ||
``` | ||
|
||
with | ||
|
||
```haskell | ||
crunchWithCtxCustom "lecture" postCtx | ||
``` | ||
|
||
Then, as you go through the lectures, replace `match "lectures/*"` with | ||
|
||
``` | ||
match "lectures/00-*" $ crunchWithCtxCustom "final" postCtx | ||
match "lectures/*" $ crunchWithCtxCustom "lecture" postCtx | ||
``` | ||
|
||
(and gradually add more and more lectures to `final` as I go through them) | ||
|
||
## New Class Checklist | ||
|
||
- [x] site.hs | ||
- [x] index.md | ||
- [x] links.md | ||
- [x] contact.md | ||
- [x] lectures.md | ||
- [x] calendar.md | ||
- [x] grades.md | ||
- [x] assignments.md | ||
- [x] piazza | ||
|
||
- [ ] canvas | ||
- [ ] github registration form | ||
- [ ] clicker registration form | ||
- [ ] 00-lambda | ||
|
||
* [-] groups | ||
* [-] seating chart | ||
|
||
## Credits | ||
|
||
This theme is a fork of [CleanMagicMedium-Jekyll](https://github.com/SpaceG/CleanMagicMedium-Jekyll) | ||
originally published by Lucas Gatsas. | ||
|
||
<!-- | ||
## ieng6 Setup | ||
1. Set the `stack-root` | ||
``` | ||
stack setup --stack-root=/software/CSE/cse130/.stack | ||
``` | ||
2. Create a shell script | ||
``` | ||
cat > fixpaths.sh | ||
cd ~/../public/bin && chmod -R a+rx * | ||
cd /software/CSE/cse130/.stack && chmod -R a+rx * | ||
``` | ||
3. For each assignment, | ||
- `git clone` it to download assignment as instructor | ||
- `stack test` it to get the relevant libs added to the stack-path | ||
- `./fixpaths.sh` to allow everyone else to read the libraries | ||
4. For each assignment, | ||
- login as student to make sure that you can `git clone` and then run `stack test` | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
title: Assignments | ||
headerImg: angles.jpg | ||
--- | ||
|
||
## Late Policy | ||
|
||
You have a total of *six late days* that you can use throughout the quarter, | ||
but no more than *four late days* per assignment. | ||
|
||
- A late day means anything between 1 second and 23 | ||
hours 59 minutes and 59 seconds past a deadline | ||
- If you submit past the late day limit, you get 0 points for that assignment | ||
- There is no penalty for submitting late but within the limit | ||
|
||
## Assignments | ||
|
||
| **HW-link** | **Name** | **Deadline (23:59:59pm)** | | ||
|:-------------------------------------------------|:------------------------|:---------------------------| | ||
| [HW #0] | Lambda Calculus | Wed 1/24 | | ||
|
||
<!-- | ||
| [HW #1] | Introduction to Haskell | Fri 2/2 | | ||
| [HW #2] | Data types | Fri 2/16 | | ||
| [HW #3] | Higher-order Functions | Fri 3/1 | | ||
| [HW #4] | Interpreters | Mon 3/13 | | ||
| [HW #5] | Classes | Sun 3/22 | | ||
--> | ||
|
||
## Sample Exam Questions | ||
|
||
Note: 2018 exams are the most representative. Older exams use OCaml instead of Haskell. | ||
Check out these [lecture notes](https://ucsd-cse130.github.io/web/lectures/02-haskell.html) | ||
for a comparison between the two languages. | ||
|
||
- [Midterm Sp 18](/static/raw/130-midterm-sp18.pdf) ([solution](/static/raw/130-midterm-sp18-solution.pdf)), | ||
|
||
- [Midterm Sp 15](/static/raw/midterm-sp15.pdf), ocaml code ported to [haskell](/static/raw/MidtermSp15.hs) | ||
|
||
- [Midterm Sp 14](/static/raw/midterm-sp14.pdf), ocaml code ported to [haskell](/static/raw/MidtermSp14.hs) | ||
|
||
- [Midterm Sp 12](/static/raw/midterm-sp12.pdf), [Midterm Wi 12](/static/raw/midterm-wi12.pdf). | ||
|
||
- [Final Sp 18](/static/raw/130-final-sp18.pdf) ([solution](/static/raw/130-final-sp18-solution.pdf)), | ||
[Final Sp 14](/static/raw/final-sp14.pdf), | ||
[Final Fa 12](/static/raw/final-fa12.pdf), | ||
[Final Sp 12](/static/raw/final-sp12.pdf), | ||
[Final Fa 11](/static/raw/final-fa11.pdf), | ||
[Final Wi 11](/static/raw/final-wi11.pdf). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: Calendar | ||
headerImg: road.jpg | ||
--- | ||
|
||
## Office Hours | ||
|
||
See CANVAS calendar for details | ||
|
||
## Calendar | ||
|
||
| **Event** | **Day** | **Time** | | ||
|:-------------|:---------|:-------------| | ||
| *Lectures* | Tu-Th | 12:30-1:50pm | | ||
| *Section* | Fri | 3:00-3:50pm | | ||
| *Midterm I* | Tu 1/30 | 12:30-1:50pm | | ||
| *Midterm II* | Th 2/22 | 12:30-1:50pm | | ||
| *Final* | Tu 3/19 | 11:30-2:30pm | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: Contact | ||
headerImg: world-map.jpg | ||
--- | ||
|
||
## Course Details | ||
|
||
- **Lectures:** Tu-Th 12:30-1:50p at Pepper Canyon 106 | ||
- **Section:** Fr 5:00-3:50p at Pepper Canyon 109 | ||
- **Announcements:** Posted on Piazza. Please check often! | ||
|
||
## Instructor | ||
|
||
- [Ranjit Jhala](https://ranjitjhala.github.io) | ||
|
||
## Teaching Assistants | ||
|
||
- [Matt Kolosick](mailto:[email protected]) | ||
- [Cole Kurashige](mailto:[email protected]) | ||
- [George Sakkas](mailto:[email protected]) | ||
|
||
## Tutors | ||
|
||
- [Rana Lulla](mailto:[email protected]) | ||
- [Matthew Peng](mailto:[email protected]) | ||
- [Melody Ruth](mailto:[email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
--- | ||
title: Final Exam Review | ||
headerImg: sea.jpg | ||
date: 2020-03-17 | ||
--- | ||
## Tips for Writing Programs about Programming Languages | ||
|
||
### Start with the base cases | ||
|
||
They are usually more straightforward and don't require thinking about recursion. | ||
|
||
### Pay attention to the types you have and what you're trying to produce | ||
|
||
My process for writing `eval env (EVar x)` looks something like: | ||
|
||
1. What is the type of `eval`? It's `Env -> Expr -> Value` where `Env = [(Id, Value)]` | ||
2. We're working with `EVar x` so we also have `x` of type `Id`. | ||
3. So at hand we have: an `Id`, an `Env` that is a `[(Id, Value)]`, and if we look at our helper functions we have a function `lookupId :: [(Id, Value)] -> Id -> Value`. | ||
4. This looks like a good solution so let's start there and we see that `lookupId env x` works and does what it should do. | ||
|
||
We can follow this for other base cases where it's sometimes even more straightforward. | ||
For `eval env (EInt i)` we have `i` of type `Int`. | ||
We also have `VInt` which takes an `Int` and produces a `Value`. | ||
And indeed the implementation is `eval env (EInt i) = VInt i`. | ||
|
||
### Contexts/Environments | ||
|
||
`env` was very important to the previous example and these contexts/environments show up frequently in programming languages. | ||
Whenever we are dealing with a variable, we probably want to do it using the environment. | ||
We will see an example of this next when talking about `EApp`. | ||
|
||
### Recursion | ||
|
||
For cases with sub `Expr`essions: these will probably be recursive. | ||
So anytime we see a case like `eval env (EApp e1 e2)` we're probably going to want to call `eval ___ e1` and `eval ___ e2`. | ||
Keep these around as `eval` let's us produce `Value`s which is our eventual goal. | ||
|
||
My first step for thinking about these "complex" expressions is to think of a specific example (doing the base cases first will help here), say `(\x -> x) 1` which we know should evaluate to `1`. | ||
This case would look like | ||
``` | ||
eval env (EApp (ELam "x" (EVar "x")) (EInt 1)) | ||
``` | ||
However, we are just using this to help us figure out how to write `eval env (EApp e1 e2)` so keep `e1 = (ELam "x" (EVar "x"))` and `e2 = (EInt 1)` in mind but don't focus too much on them. | ||
|
||
At this point we have hopefully written the `eval` cases for `ELam` and `EInt`. | ||
So we know that `eval env e1` in this case will return `VClos env "x" (EVar "x")`. | ||
We also know that `eval env e2` will return `VInt 1`. | ||
|
||
Now we see that we're dealing with a variable particularly the `"x"` argument of the closure. | ||
A closure is a function values so it is waiting for an argument to substitute for `"x"`. | ||
What does substitution mean though? | ||
Here substitution means that, when we evaluate the body (`EVar x`), we want it to return `1`. | ||
When does `eval ___ (EVar x)` return `1`? | ||
Why when `___` has the binding `(x, VInt 1)`. | ||
|
||
Now we have arrived at the partial implementation: | ||
``` | ||
eval env (EApp e1 e2) = eval (x, v2):___ body | ||
where | ||
VClos closEnv x body = eval env e1 | ||
v2 = eval env e2 | ||
``` | ||
|
||
Lastly we have to figure out what to put as the rest of the environment when evaluating `body`. | ||
Here it is time to once again take stock of what types of things we have, in particular, what things of type `Env` we have (it's `env` and `closEnv`). | ||
Now it pays to think about the case of `eval env (ELam x body) = VClos env x body`. | ||
Remember that the `env` when evaluating `(ELam x body)` is the `closEnv` in the `EApp` case. | ||
Here it pays to try to think about why we have `closEnv`. | ||
It captures the environment when a function is defined so let's think about where that might be the case: | ||
``` | ||
let x = 1 in | ||
let f = \y -> x in | ||
let x = 2 in | ||
f 1 | ||
``` | ||
This should evaluate to `1`. Importantly for our implementation of `eval` for `EApp` it is the `closEnv` when defining the lambda that contains `(x, VInt 1)` whereas `env` at the application site contains `(x, VInt 2)`. | ||
So we arrive at | ||
``` | ||
eval env (EApp e1 e2) = eval (x, v2):closEnv body | ||
where | ||
VClos closEnv x body = eval env e1 | ||
v2 = eval env e2 | ||
``` | ||
|
||
### Don't be more specific than you need to be | ||
|
||
While we used `EInt 1` as the argument in our example we never had to look inside of it, all we had to do was call `eval env e2`. | ||
You should try to do this whenever possible: if you don't need to know specific information about a subterm besides what it evaluates to (or whatever other thing you are computing) then just do the recursive call on it. | ||
|
||
For non-recursive `ELet` we don't actually care what `e1` or `e2` in `let x = e1 in e2` are. | ||
All we need to do is evaluate `e1` to `v1`, see that we have a variable, add `(x, v1)` to the environment, and then evaluate `e2` in the new environment. | ||
In that description it never mattered what the actual expressions `e1` and `e2` are so we shouldn't pay attention to that. | ||
Just treat them as abstract expressions. | ||
|
||
This is in contrast to `e1` in the `EApp` case because there we need to know that the first thing evaluates to a function. | ||
But notice that we only care that it *evaluates* to a function, so we only need to look at `e1` after evaluating it. | ||
This is a good general rule for writing recursive functions for programming languages: poke the subterms with the function you're defining (here call `eval env e1`), *then* look at what you get back. | ||
|
||
## WRITE AND RUN TESTS | ||
|
||
When writing a case have a test in mind and run your code on it. | ||
When we were writing the `eval` case for `EApp` above we had the test case `(\x -> x) 1` in mind. | ||
After you write the code hop over to GHCI and run that test case and see if it does what you expect. | ||
Don't wait until you've implemented every case and then test some large chunk of code because debugging that will be hard. | ||
|
||
## Good luck. |
Oops, something went wrong.