@@ -353,7 +353,19 @@ available in the *Prelude* (check out its type!).
353353 ` handleRequest ` . This should allow you to completely get rid
354354 of the ` where ` block.
355355
356- 2 . Define an enumeration type listing the four
356+ 2 . Refactor ` handleRequest ` to use ` Either ` , such that
357+ ` handleRequest : DB -> Request -> Either Failure Album ` , where
358+
359+ ``` idris
360+ data Failure : Type where
361+ UnknownUser : Email -> Failure
362+ InvalidPassword : Failure
363+ AccessDenied : Email -> Album -> Failure
364+ ```
365+
366+ Hint: You may find nested ` case ` statements helpful.
367+
368+ 3 . Define an enumeration type listing the four
357369 [ nucleobases] ( https://en.wikipedia.org/wiki/Nucleobase )
358370 occurring in DNA strands. Define also a type alias
359371 ` DNA ` for lists of nucleobases.
@@ -363,7 +375,7 @@ available in the *Prelude* (check out its type!).
363375 ` 'A' ` , ` 'a' ` . Note, that this function might fail, so adjust the
364376 result type accordingly.
365377
366- 3 . Implement the following function, which tries to convert all
378+ 4 . Implement the following function, which tries to convert all
367379 values in a list with a function, which might fail. The
368380 result should be a ` Just ` holding the list of converted
369381 values in unmodified order, if and
@@ -376,11 +388,11 @@ available in the *Prelude* (check out its type!).
376388 You can verify, that the function behaves correctly with
377389 the following test: ` traverseList Just [1,2,3] = Just [1,2,3] ` .
378390
379- 4 . Implement function ` readDNA : String -> Maybe DNA `
391+ 5 . Implement function ` readDNA : String -> Maybe DNA `
380392 using the functions and types defined in exercises 2 and 3.
381393 You will also need function ` unpack ` from the * Prelude* .
382394
383- 5 . Implement function ` complement : DNA -> DNA ` to
395+ 6 . Implement function ` complement : DNA -> DNA ` to
384396 calculate the complement of a strand of DNA.
385397
386398## The Truth about Function Arguments
0 commit comments