This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
CIS194/Lecture 03/LogAnalysis/LogAnalysis.hs
2016-10-17 15:01:20 +00:00

29 lines
611 B
Haskell

module LogAnalysis where
import Text.Read ( readMaybe )
data MessageType = Info
| Warning
| Error Int
deriving (Show, Eq)
type Timestamp = Int
data LogMessage = LogMessage MessageType Timestamp String
deriving (Show, Eq)
data MaybeLogMessage = ValidLM LogMessage
| InvalidLM String
deriving (Show, Eq)
data MaybeInt = ValidInt Int
| InvalidInt
deriving (Show, Eq)
readInt :: String -> MaybeInt
readInt s
| Just i <- readMaybe s = ValidInt i
| otherwise = InvalidInt
-- parseMessage :: String -> MaybeLogMessage