Commit a604456d authored by Iustin Pop's avatar Iustin Pop
Browse files

Text.hs: change to use sepSplit

The new sepSplit function can split based on empty lines, so we remove
the hackish text splitting from before and simply use sepSplit. This
is needed as the addition of extra sections would have increased the
code linearly, which we don't want :)
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarBalazs Lecz <>
parent 748d5d50
......@@ -168,20 +168,17 @@ parseData :: String -- ^ Text data
-> Result (Group.List, Node.List, Instance.List, [String])
parseData fdata = do
let flines = lines fdata
(glines, nilines) = break null flines
(nlines, ilines) = break null (tail nilines)
nfixed <- case nlines of
[] -> Bad "Invalid format of the input file (no node data)"
xs -> Ok xs
ifixed <- case ilines of
[] -> Bad "Invalid format of the input file (no instance data)"
_:xs -> Ok xs
(glines, nlines, ilines) <-
case sepSplit "" flines of
[a, b, c] -> Ok (a, b, c)
xs -> Bad $ printf "Invalid format of the input file: %d sections\
\ instead of 3" (length xs)
{- group file: name uuid -}
(ktg, gl) <- loadTabular glines loadGroup
{- node file: name t_mem n_mem f_mem t_disk f_disk -}
(ktn, nl) <- loadTabular nfixed (loadNode ktg)
(ktn, nl) <- loadTabular nlines (loadNode ktg)
{- instance file: name mem disk status pnode snode -}
(_, il) <- loadTabular ifixed (loadInst ktn)
(_, il) <- loadTabular ilines (loadInst ktn)
return (gl, nl, il, [])
-- | Top level function for data loading
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment