Из туториала
-- | A symbol in the map of an ASCII roguelike
data Symbol
= -- | A wall, depicted by a # character
Wall
| -- | A water cell, depicted by a ~ character
Water
deriving (Eq, Show)
-- | A parser for the symbol of a single cell. Used in 'parseElement' below.
parseSymbol :: Parser Symbol
parseSymbol = do
c <- anySingle
case c of
'#' -> return Wall
'~' -> return Water
_ -> fail $ "Unknown symbol: " <> [c] -- See below for how to avoid this case altogether (in parseLineElement)