Note: There are a lot of functions this week. The long list is meant to give you flexibility in choosing what you care to work on. Don’t spend more than, say, 8 hours on this!

  1. Write the following functions, adapted from their list versions. You will need EVec and Fin for these. Use as tight a constraint on EVec as you can.

    1. concatMap
    2. unfoldr
    3. takeWhile
    4. dropWhile
    5. dropWhileEnd
    6. filter
    7. (!!) (uses Fin)
    8. elemIndex (uses Fin)
    9. elemIndices (uses EVec and Fin)
    10. findIndex (uses Fin)
    11. findIndices (uses EVec and Fin)
    12. nub
    13. delete (this can get a tighter constraint than, say, filter)
    14. (\\)
    15. union
    16. intersect
  2. The following functions cannot be translated to work on Vec with the existing structures we have. But you know enough to come up with fresh GADTs to encode the right invariants. Aim for your type indices to be as expressive as possible.

    1. span
    2. break
    3. partition
    4. group