<div dir="ltr"><div class="gmail-votecell gmail-post-layout--left" style="margin:0px;padding:0px 16px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Liberation Sans",sans-serif;font-size:13px;vertical-align:top;box-sizing:inherit;width:auto;color:rgb(35,38,41)"><div class="gmail-js-voting-container gmail-d-flex gmail-jc-center gmail-fd-column gmail-ai-stretch gmail-gs4 gmail-fc-black-200" style="padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;display:flex"><div class="gmail-js-vote-count gmail-flex--item gmail-d-flex gmail-fd-column gmail-ai-center gmail-fc-black-500 gmail-fs-title" style="margin:2px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;font-size:1.61538rem;display:flex">-1</div><button class="gmail-js-vote-down-btn gmail-flex--item gmail-s-btn gmail-s-btn__unset gmail-c-pointer" aria-label="Down vote" aria-describedby="--stacks-s-tooltip-lrilj2op" style="margin:2px;box-sizing:inherit;font:unset;padding:0px;border-width:initial;border-style:none;border-color:initial;border-radius:0px;background-image:none;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;outline:none"></button><button class="gmail-js-bookmark-btn gmail-s-btn gmail-s-btn__unset gmail-c-pointer gmail-py4 gmail-js-gps-track" aria-label="Bookmark" aria-describedby="--stacks-s-tooltip-zgzq3nn9" style="margin:0px;box-sizing:inherit;font:unset;padding:0px;border-width:initial;border-style:none;border-color:initial;border-radius:0px;background-image:none;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;outline:none"></button><a class="gmail-js-post-issue gmail-flex--item gmail-s-btn gmail-s-btn__unset gmail-c-pointer gmail-py6 gmail-mx-auto" href="https://stackoverflow.com/posts/69702739/timeline" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-nssm5w6m" style="margin:2px;padding:0px;border:none;font:unset;vertical-align:baseline;box-sizing:inherit;text-decoration-line:none;color:unset;display:inline-block;border-radius:0px;background:none;outline:none;text-align:center"></a></div></div><div class="gmail-postcell gmail-post-layout--right" style="margin:0px;padding:0px 16px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Liberation Sans",sans-serif;font-size:13px;vertical-align:top;box-sizing:inherit;width:auto;min-width:0px;color:rgb(35,38,41)"><div class="gmail-s-prose gmail-js-post-body" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:15px;vertical-align:baseline;box-sizing:inherit;width:401px"><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;clear:both">I am new to haskell and I need to create a simple word processor. It needs to read text from the cmd and implement functions that would edit functions found in the text so some other text.All functions in the text are odered. Each function i.e section,table,figures and ref must be located and numbered independently based on the order of occurence. Since tables and figures are within the sections function(just like a book), when a new section is encountered you will reset the value of tables and figures. So i did a loop where the tables and figures are inside the section loop when searching for the functions. The functions all start with this '' character (escape character) and must be replaced with text using this method: \Section{title}{id}: -> "Section n: title". Where n is the section number. \table{title}{id} : -> "Table n.m : title". Where n is the number of the last section encountered and m is the table number. And so on.</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;clear:both">I need help because my code isn't running.This is the code:</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;clear:both">import Text.Format<br>import Data.Text.Internal.Search<br>import Data.Text<br><br>s = count . "section" -- count number of occurences of a certain word<br>t = count . "table"<br>f = count .  "Figure"<br>r = count . "ref"    <br><br> <br>forLoop :: Int - Int - Int - Int<br><br>forLoop  s value =<br>    if  i < s<br>        then forLoop (i + 1) format "Section{title}{id}" [show i, show {title}]<br>      then replace "Section{i}{title}" "Section {i}:{title}"<br>        else value<br><br><br>        forLoop  t value =<br>           if  j < t<br>             then forLoop (j + 1) format "table{title}{id}" [show i.j, show {title}] --change the text<br>           then replace "table{i}.{j}{title}" "Table {i}.{j} : {title}" <br>         else value<br><br>  forLoop  f value =<br>           if  k < f<br>             then forLoop (k + 1) format "figure{title}{id}" [show i.k, show {title}] --change the text<br>          then replace "Figure{title}{id}" "Figure {i}.{k} : {title}"<br>               else value<br>            <br><br>            if "ref{id}" == "table{title}"<br>            then forLoop  r value =<br>                            if  l < r<br>                             then forLoop (l + 1) format "ref{id}" [show {title}] --change the text<br>                              then replace "ref{id}" "see {title} {i}.{j}"<br>                          else value<br>            else Nothing<br><br>                if "ref{id}" == "Figure{title}"<br>           then forLoop  r value =<br>                            if  m < r<br>                             then forLoop (m + 1) format "ref{id}" [show {title}] --change the text<br>                              then replace "ref{id}" "see {title} {i}.{m}"<br>                          else value<br>            else Nothing<br><br>                if "ref{id}" == "Section{title}"<br>          then forLoop r value =<br>                        if n < r<br>                   then forLoop(n+1) format "ref{id}" [show{title}]<br>                    then replace "ref{id}" "see {title} {i}"<br>                  else value<br>            else nothing<br></p></div></div></div>