packages feed

simtreelo 0.1.0.2 → 0.1.0.3

raw patch · 2 files changed

+58/−55 lines, 2 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

Data/Simtreelo.hs view
@@ -48,79 +48,82 @@ -- -- Returns the first error message on failure, or the 'Tree' on success loadString str = do-	let (first:s:r) = lines str-	let (_,spaces) = separate' s-	(tree,_,_) <- if spaces /= [] then-		parse (s:r) 2 1 (Just spaces) first-	else-		parse (s:r) 2 0 Nothing first-	return tree+  let (first:s:r) = lines str+      (_,spaces) = separate' s+  (tree,_,_) <- if spaces /= [] then+                  parse (s:r) 2 1 (Just spaces) first+                else+                  parse (s:r) 2 0 Nothing first+  return tree  -- | Just applies loadString to the contents of the given file loadFile fname = do-	str <- readFile fname-	return $ loadString str+  str <- readFile fname+  return $ loadString str  parse [] ln _ _ _ = Right ([],[],ln) parse (h:r) ln d Nothing comment = do-	let (name,spaces) = separate' h-	if (strip name comment) == "" then parse r (ln+1) d Nothing comment-	else do-		let (indentor,depth) = if spaces == "" then (Nothing,0) else (Just spaces,1)-		(children,rest,ln') <- parse r (ln + 1) (d + 1) indentor comment-		if depth == d then do-			(siblings,rest',ln'') <- parse rest ln' d indentor comment-			return (Node{rootLabel = (strip name comment), subForest = children}:siblings, rest',ln'')-		else return ([],(h:r),ln)+  let (name,spaces) = separate' h+  if (strip name comment) == "" then parse r (ln+1) d Nothing comment+    else do    +    let (indentor,depth) = if spaces == "" then (Nothing,0) else (Just spaces,1)+    (children,rest,ln') <- parse r (ln + 1) (d + 1) indentor comment+    if depth == d then do+      (siblings,rest',ln'') <- parse rest ln' d indentor comment+      return (Node{rootLabel = (strip name comment), subForest = children}:siblings, rest',ln'')+      else return ([],(h:r),ln)+ parse (h:r) ln d (Just indentor) comment = do-	(name,depth) <- separate h indentor ln-	if (strip name comment) == "" then parse r (ln+1) d (Just indentor) comment-	else do-		(children,rest,ln') <- parse r (ln + 1) (d + 1) (Just indentor) comment-		if depth == d then do-			(siblings,rest',ln'') <- parse rest ln' d (Just indentor) comment-			return (Node{rootLabel = (strip name comment), subForest = children}:siblings, rest',ln'')-		else return ([],(h:r),ln)+  (name,depth) <- separate h indentor ln+  if (strip name comment) == "" then parse r (ln+1) d (Just indentor) comment+    else do+    (children,rest,ln') <- parse r (ln + 1) (d + 1) (Just indentor) comment+    if depth == d then do+      (siblings,rest',ln'') <- parse rest ln' d (Just indentor) comment+      return (Node{rootLabel = (strip name comment), subForest = children}:siblings, rest',ln'')+      else+      return ([],(h:r),ln)  -- checks if the first argument is a prefix of the second -- returns whether this is true and what is left of the second after the prefix isPrefix [] r = (True,r) isPrefix i [] = (False,[]) isPrefix (hi:ri) (h:r)-	| h == hi =-		let (prefix,rest) = isPrefix ri r in-		(prefix,if prefix then rest else h:r)-	| otherwise = (False,h:r)+  | h == hi =+    let (prefix,rest) = isPrefix ri r in+    (prefix,if prefix then rest else h:r)+  | otherwise = (False,h:r)  separate' [] = ([],[]) separate' (h:r)-	| h == ' ' || h == '\t' = let (name,spaces) = separate' r in-		(name,h:spaces)-	| otherwise = (h:r,"")+  | h == ' ' || h == '\t' = let (name,spaces) = separate' r in+  (name,h:spaces)+  | otherwise = (h:r,"")  strip [] _ = [] strip (h:r) [] =-	let rest = strip r [] in-	if rest /= "" then h:rest-	else-		if h == ' ' || h == '\t' then "" else [h]+  let rest = strip r [] in+  if rest /= "" then h:rest+  else+    if h == ' ' || h == '\t' then "" else [h] strip (h:r) comment =-	let (prefix,_) = isPrefix comment (h:r) in-	if prefix then ""-	else-		let rest = strip r comment in-		if rest /= "" then h:rest-		else-			if h == ' ' || h == '\t' then "" else [h]+  let (prefix,_) = isPrefix comment (h:r) in+  if prefix then ""+  else+    let rest = strip r comment in+    if rest /= "" then h:rest+    else+      if h == ' ' || h == '\t' then "" else [h]  separate a [] _ = Right (a,0) separate [] _ _ = Right ([],0) separate line indentor lineNumber = do-	let (prefix,rest) = isPrefix indentor line-	if prefix then do-		(name,depth) <- separate rest indentor lineNumber-		return (name,depth + 1)-	else if head rest == ' ' || head rest == '\t' then-		Left $ "Invalid indentation at line " ++ show lineNumber-	else-		Right (line,0)+  let (prefix,rest) = isPrefix indentor line+  if prefix then do+    (name,depth) <- separate rest indentor lineNumber+    return (name,depth + 1)+    else+    if head rest == ' ' || head rest == '\t' then+      Left $ "Invalid indentation at line " ++ show lineNumber+      else+      Right (line,0)
simtreelo.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.0.2+version:             0.1.0.3  -- A short (one-line) description of the package. synopsis:            Loader for data organized in a tree@@ -32,7 +32,7 @@ maintainer:          marcelogmillani@gmail.com  -- A copyright notice.-copyright:           (c) 2014 Marcelo Garlet Millani+copyright:           (c) 2014, 2015 Marcelo Garlet Millani  category:            Data @@ -57,7 +57,7 @@   -- other-extensions:          -- Other library packages from which modules are imported.-  build-depends:       base >=4.7 && <4.8, containers+  build-depends:       base >=4.8 && <4.9, containers   exposed-modules:     Data.Simtreelo   default-extensions: DoAndIfThenElse, FlexibleInstances