I need some advice on how to list only words from Text branches in this code I have programmed.
data Article = Text String
| Section String [Article] deriving (Show)
myArticle :: Article
myArticle = Section "Document" [
Section "Introduction" [
Text "My intoduction",
Section "Notation" [Text "alpha beta gamma"]],
Section "Methods" [
Section "Functional Programming" [Text "FPR"],
Section "Logical Programming" [Text "LPR"]],
Section "Results" [Text "All is great"]]
tex :: Article -> [String]
tex (Text x) = [x]
tex (Section x (l:ls)) = tex l
I tried to call ls in the tex function, but it throws me an error. I don't know how to proceed.