CIS 552: Advanced Programming

Fall 2017

Note: this is the stubbed version of module MonoidFoldable. You should
download the lhs version of this
module and replace all parts marked undefined.
Eventually, the complete
version will be made available.

The assignment shows you that numbers can instantiate this class in multiple ways. Like numbers, Booleans can be made an instance of the Monoid class in two different ways.

>newtypeAll=All { getAll ::Bool }
>newtypeAny=Any { getAny ::Bool }

Make sure that you understand these type definitions. We are defining a type All with single data constructor (also called All). The argument of this data constructor is a record with a single field, called getAll. What this means is that All and getAll allow us to convert Bools to All and back.

λ> :t All
All :: Bool -> All
λ> :t getAll
getAll :: All -> Bool

Above, newtype is like data, but is restricted to a single variant. It is typically used to create a new name for an existing type. This new name allows us to have multiple instances for the same type (as below) or to provide type abstraction (like SortedList in the HW).

Your job is to complete these instances that can tell us whether any of the booleans in a list are true, or whether all of the booleans in a list are true. (See two test cases below for an example of the behavior.)