concept List in category haskell

appears as: List, The List
Get Programming with Haskell

This is an excerpt from Manning's book Get Programming with Haskell.

Another important type is List. Here are a few examples.

Listing 11.3. List types
values :: [Int] values = [1,2,3] testScores :: [Double] testScores = [0.99,0.7,0.8] letters :: [Char] letters = ['a','b','c']

31.2.4. The List context—processing a list of candidates

It should come as no surprise that List is also a Monad, as List is an example of virtually every feature of Haskell. In the next lesson, you’ll look more into what this means, but for now let’s see what happens when you want to look at a list of candidates.

Listing 31.15. A list of possible candidates
candidates :: [Candidate] candidates = [candidate1 ,candidate2 ,candidate3]

Because List is an instance of Monad, you should be able to convert your other assess-Candidate function into an assessCandidateList function. If you do and pass in a list, you get a useful result.

Listing 31.16. Assessing a list of candidates using List as a Monad
assessCandidateList :: [Candidate] -> [String] assessCandidateList candidates = do candidate <- candidates let passed = viable candidate let statement = if passed then "passed" else "failed" return statement
Figure 32.1. Generating lists by thinking of List as a Monad