Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP1100/1130 Assignment
This assignment is worth 10% of your nal grade.
Deadlines: Sunday April 14, 2023, at 11:00pm Canberra time sharp
Please note that Daylight Savings ends on Sunday 7 April. Note: Late submissions will not be
marked unless you have an approved extension. Extensions can only be applied for through the
Extension App. Students with Education Access Plans still need to use this App.
Required Knowledge
If you have nished the Week 3 lab, you should be able to attempt Part A.
If you have nished the Week 4 lab, you should be able to attempt the majority of the assignment. Some
parts require recursion over lists, which is covered in the Week 5 lab.
Overview of Tasks
COMP1100 Marks COMP1130 Marks
Task 1: Helper Functions 20 marks 10 marks
Task 2: Rendering Shapes 45 Marks 40 Marks
Task 3: Handling Events 35 Marks 30 Marks
1130 Extensions - 38 Marks
Report 0 marks 2 marks
Total 100 marks 120 marks
Part A of the assignment requires you to complete Task 1.
Part B of the assignment requires you to complete all other assigned tasks.
As you complete each task (or even each function within a task), once your code compiles without errors,
you should commit and push your work to git with a sensible commit message so your work is safely
recorded.
Part A (Task 1) differs from the rest of the assignment in that you are able to ask for detailed help
from tutors, peers, or other sources of assistance without this being considered plagiarism. This is
to make sure that you have the help you need to get started on your rst programming assignment.
We recommend you attempt Part A on your own before asking for help, so that you have something
to discuss. Help from tutors is best sought through drop-in consultations or the Ed Discussions
forum because, during labs, tutors are usually busy helping with that week’s exercises. Usual
academic misconduct standards apply to Part B of the assignment. You may also ask for help from
tutors for this later parts, but the help you will receive will be focused on conceptual understanding
rather than details of the tasks themselves.
Gitlab CI
You may notice a box in your repository on the Gitlab web view, looking something like this:
To help you ensure your submitted code is compiling, we’ve added a Continuous Integration (CI) script to
this assignment. The CI will check that your code compiles, and run some tests on your code.
There’s three states your CI can be in:
A red x, indicating your code is not compiling. This is something you should x as soon as possible, as
non-compiling code will not receive marks. You could x this by either resolving the error, or by
commenting out the erroring code to still submit it.
An orange exclamation: this indicates that one of the tests in tests/ShapesTest.hs isn’t passing.
This is to be expected at the start of the assignment, but once you have nished Part A of the
assignment, this might indicate an issue with your code.
A green tick: this indicates that your code is compiling, and all the tests are passing.
Getting Started
Fork the assignment repository and create a project for it in VSCodium, following the same steps as
in Lab 2.
Add our version of the repository as a remote called upstream . This allows us to provide additional
xes in the case they are required. You do this by doing the following:
Go to the command palette in VSCode (or VSCodium) by pressing Ctrl + Shift + p
Type git remote
Click Git: Add Remote
Enter upstream into the box for the remote name
Put the following URL as the remote url:
Overview of the Repository
Most of your code will be written to Haskell les in the src/ directory. We are using the Model-View-
Controller pattern to structure this assignment. Each le is called a module, and we use modules to group
related code together and separate unrelated code.
Model.hs
The Model is a data type that describes the state of the running program. The program will move to new
states (new values of type Model ) in response to user actions, as dened by the Controller.
View.hs
The View turns the Model into something that can be shown on the screen; in this project, that is the
CodeWorld Picture type.
Controller.hs
The Controller considers user input (and other events), along with the current Model, and uses that to
decide what the new Model should be.
Other Files
tests/ShapesTest.hs contains some unit tests - simple checks that can help to verify that Part A
of your program is working correctly. You are not required to write your own tests for this assignment,
but you might nd it useful to do so. COMP1130 students might need to modify these tests, as
explained below.
tests/Testing.hs is a small testing library used by tests/ShapesTest.hs . You are not
required to understand it for this assignment.
app/Main.hs ties your functions together into the nal program that runs. You are not required to
understand it.
comp1100-assignment1.cabal tells the cabal build tool how to build your assignment. You are
not required to understand this le, and we will discuss how to use cabal below.
Setup.hs tells cabal that this is a normal package with no unusual build steps. Some complex
packages (that we will not see in this course) need to put more complex code here. You are not
required to understand it.
.gitlab-ci.yml and Dockerfile are there to support the continuous integration. You are not
required to understand them.
Overview of Cabal
cabal is the build tool for Haskell programs and libraries. It provides several useful commands:
cabal v2-build : Compile your assignment. Note that because of some code provided for you by
us you will see some warnings about unused variables; you will x these warnings during Task B, so
may ignore them for Task A.
cabal v2-run shapes : Build your assignment (if necessary), and run the shapes program. Note
that you will need to enter Ctrl-C in your terminal to exit the program.
cabal v2-repl comp1100-assignment1 : Run the GHCi interpreter over your project. This gives
you the same ghci environment you use in labs, but with the assignment code loaded. (Aside: REPL is
the name for interactive sessions like GHCi - it stands for read-eval-print loop. Many modern
languages have REPLs.)
cabal v2-test : Build and run the tests. Tests will abort on the rst failure, or the rst call to a
function that is still undefined .
Interacting with the Program
You use a web browser to interact with the shapes program that you launched with
cabal v2-run shapes . Once you have completed the assignment, it will respond to the following
actions:
Action Effect
Esc (key) Clear the canvas and all settings.
1 / 2 (key) Display the sample images.
C (key) Change colour (of shape to draw).
T (key) Change tool (type of shape to draw).
Backspace / Delete
(key)
Remove the last added shape.
Spacebar (key) When drawing a polygon, nish drawing the polygon, adding it to the canvas.
Otherwise, nothing.
D (key) Print the current Model to the terminal (useful for testing).
Click-drag-release
(mouse)
Used to draw various shapes.
Click (mouse) Used to draw various shapes.
Task 1: Helper Functions (COMP1100: 20 marks, COMP1130:
10 marks)