CS 380 Homework #8
Prof. Richard Eisenberg
Spring 2017
Due date: Wednesday, April 12, 2017
This week’s assignment is to update your computer algebra solver from Homework #3 to use GADTs to eliminate the need for error. This is done by adding a new Step 0 to the procedure that you followed in Homework #3: convert the Equation to the new LEquation type that allows only linear equations. The type is declared in the LArith module I have provided.
Here are the relevant modules:
The bundle of modules includes a Main module. This is not part of the assignment, but using it, you can say ghc Main at the command-line, and GHC will build an executable Main for you that you can use to solve equations.
If it’s helpful, the solution to the last Halgebra assignment is on Moodle.
Here is the breakdown of the functions you have been asked to write for your type-level portfolio:
Functions that work straightforwardly on Vec (and, or, any, map, unzip, insert, sort, foldl, foldr, scanl, scanr, mapAccumL, mapAccumR): 13
Functions that are partial on lists but can be made total on Vecs (last, uncons, foldl1, foldr1, scanl1, scanr1): 6
Functions that require some type families or other type-level twists (init, stripPrefix): 2
Functions that require interacting with singletons (null, length, take, drop, replicate, splitAt): 6
Proofs of reasonable difficulty (commutativity of +, associativity of +): 2
Proofs of unreasonable difficulty (commutativity of *): 1
VecList functions of reasonable difficulty (intersperse): 1
VecList functions of unreasonable difficulty (inits, tails, intercalate, subsequences, permutations, transpose): 6
EVec functions (concatMap, unfoldr, takeWhile, dropWhile, dropWhileEnd, filter, nub, delete, (\\), union, intersect): 11
Fin functions ((!!), elemIndex, elemIndices, findIndex, findIndices): 5
Functions for which you need to write your own GADT (span, break, partition, group): 4
The Halgebra solver: one big problem.
This adds up to:
The total here is 99 points, but the goal isn’t to get to 100. Throwing out the unreasonable problems gives us 64. Arriving at a power of 2 at this point is auspicious. (It certainly wasn’t planned!) Here are the point values and how much, roughly, they are worth on the 4.0-point scale:
As always, do let me know if you have any questions.