Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 19 lines (15 sloc) 0.55 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import qualified Data.ByteString.Lazy.Char8 as L

closing :: L.ByteString -> Maybe Int
closing = readPrice . (!!4) . L.split ','

readPrice :: L.ByteString -> Maybe Int
readPrice str =
    case L.readInt str of
      Nothing -> Nothing
      Just (dollars, rest) ->
          case L.readInt (L.tail rest) of
            Nothing -> Nothing
            Just (cents, _) -> Just (dollars * 100 + cents)

highestClose = maximum . (Nothing:) . map closing . L.lines

highestCloseFrom path = do
  contents <- L.readFile path
  print (highestClose contents)
Something went wrong with that request. Please try again.