LMU ☀️ CMSI 3801
LANGUAGES AND AUTOMATA I
HOMEWORK #3 Due: 2025-10-22

Learning Objectives

With this assignment you will demonstrate:

Readings and Videos

Please:

Instructions

Work in teams of 1 to 4 students.

Do all work in the GitHub repository you created in the previous assignment.

Remember: There must be only one official repository per group.

Repository

Add files according to the folder structure below. You will be implementing the assigned functions and classes from scratch. The test files have been written for you; follow the links to obtain them.

.
├── code/
│   ├── typescript/
│   │   ├── exercises.ts
│   │   └── package.json
│   │   └── tsconfig.json
│   │   └── exercises.test.ts
│   ├── haskell/
│   │   ├── exercises.hs
│   │   └── ExercisesTest.hs

Code

Implement—for TypeScript and Haskell—modules with the following functions and types. You must provide full and explicit type annotations for all functions (and methods), even though each language is capable of inferring every type.

Strive to use the most idiomatic constructs of each language in your solutions.

Generative AI is permitted for this assignment; however, there is no guarantee that it will produce code that meets all of the requirements. Do not try to prompt your way to working solutions. Make sure to thoroughly review and test any code produced by AI tools.

To use the supplied unit tests, make sure you’ve created the test-data folder and its associated files as described in the instructions for Homework 2. Run the tests in their corresponding code folders, with the following commands:

Exercises

In the file exercises/hw3.md, provide solutions to the following problems. You will need to do research, as not all of these topics were covered in class. For exercises that ask you for prose answers, please be comprehensive and demonstrate a broad understanding. But avoid long-winded, silly gen-ai answers. Expect deductions for verbatim copies of AI slop. Be precise and concise.

  1. Show how to constructively define the type of trees of elements of type $t$.
  2. Give a definition by cases for the exponentiation of natural numbers.
  3. (a) Which are the inhabitants of $\textsf{Bool} + \textsf{Unit}$? (b) Which are the inhabitants of $\textsf{Bool} \mid \textsf{Unit}$?
  4. (a) Which are the inhabitants of $\textsf{Bool} \times \textsf{Unit}$? (b) Which are the inhabitants of $\textsf{Bool} \rightarrow \textsf{Unit}$?
  5. What are the major arguments put forward in the article The String Type is Broken?
  6. Can you give a type to $(\lambda x.(x\:x))(\lambda x.(x\:x))$? If so, what is it? If not, why not?
  7. Represent $x \not\in A$ in function notation.
  8. What is a pure function? Why do we care about these things?
  9. How does Haskell isolate pure and impure code?
  10. In TypeScript, which of | or & is closer to the idea of “subclassing” or “inheritance” from Python? Why? (An example will help!)

Please use professional and well-structured Markdown formatting for your answers. Take pride in your work. Show you care.

Submission

To submit your work, choose one and only one team member to submit to BrightSpace (1) the names of all team members, (2) the URL of your private repository, and (3) an affidavit for each team member stating that they have done the assigned book readings and reviewed the aforementioned course notes pages.

Teamwork

Remember that, when working in teams, all team members should participate in generating solutions and are responsible for understanding all submitted answers. Ideally, each team member should produce individual answers for all exercises, and the team should combine them to produce the ultimate submissions.

Grading

You will be graded both on the correctness of your solutions, adherence to each language’s conventions, the following of the assignment instructions, and the cleanliness of the repository. Feedback will be in the form of deductions for such things as:

This list is not exhaustive, but should help in getting you used to paying attention to your submissions and taking pride in your work. Note that most code editors have plugins that will auto-format your code and even look for suspicious coding practices. You are strongly encouraged to use them.

Your homework submission will be the state of your repository on your main branch, at 18:00 in the America/Los Angeles time zone on the due date.