I want to use Haskell to format Text with giving Strings and length of the line. But keep getting a same unknown error at "chunks" function for no reason!! Here is the code:
module Format where
data Format = Flushleft | Justify | Flushright
-- Help-function for chunks
oneChunk :: [String] -> [[String]]
oneChunk [] = [[]]
oneChunk (s:ls) = [words s] ++ oneChunk ls
chunks :: Int-> [String]-> [[String]]
chunks i s = chunk' i (oneChunk s) where
chunk' i [[]] = [[]]
chunk' i (fi:se:ls)
| (length fi) + (length se) < i = [fi ++ se]
++ chunk' i (se:ls)
| otherwise = [fi] ++ [se] ++ chunk' i (se:ls)
Here is the error message:
Format.hs:13:14: error:
parse error (possibly incorrect indentation or mismatched brackets)
|
13 | | (length fi) + (length se) < i = [fi ++ se] ++
chunk' i (se:ls)
|