module XML.Utilities where
import Data.Maybe (fromMaybe)
import Text.Read (readMaybe)
fstOfThree :: (t1, t2, t3) -> t1
fstOfThree (x,_,_) = x
clearIdUnsafe :: String -> String
clearIdUnsafe [] = error "Error reading id"
clearIdUnsafe l = if isNum (last l) then clearId (init l) ++ [last l] else ""
where
isNum x = x `elem` "0123456789"
clearId :: String -> String
clearId [] = ""
clearId l = if isNum (last l) then clearId (init l) ++ [last l] else ""
where
isNum x = x `elem` "0123456789"
toN :: String -> Int
toN x = fromMaybe (error $ "Error converting id (" ++ x ++ ") to number") (readMaybe x :: Maybe Int)