Solution 1: Recursive version

myLength list = case list of [] -> 0 head :: tail -> 1 + myLength tail

Solution 2: Using List.foldl

List.foldl

myLength = List.foldl (\_ b -> b + 1) 0