Practical Haskell

  1. Write a Haskell program that loops, asking the user for a number and then reporting the number’s prime factors. Exit when the user enters in something other than a positive number.

  2. Implement the following utilities in Haskell:

    1. cat
    2. echo
    3. ls, with its -F option
    4. cp

    The modules System.IO and System.Directory will be helpful.

  3. (Challenge) Ponder how to take your solution to (1) and add fancy types to it. Note that prime factorization has a simple specification: it takes a number and produces a list of numbers, each of which is prime and the product of which equals the original number. If you have your algorithm run over SNats, you should be able to create a custom list-like GADT for your output that captures these properties. You can then use such a structure to verify your algorithm.