0

I'm trying to read in a string from a file, which works fine. But trying to replace punctuation marks with nothing to delete them, it gives me always the same message. My program part so far looks like this:

module HA

where

import FPH
import Data.List

let contents2 = replace "." "" sonnet18
let contents3 = replace "!" "" contents2

sonnet18 is a string in the file FPH.hs. I tried a couple ways to replace it, but get always the exception "parse error (possibly incorrect indentation or mismatched brackets) It doesn't say much and looking it up, didn't help yet. All indentations are four whitespaces and so on. I can't find the mistake. I'm grateful for any help.

13
  • After adding the do-block it just gives me another error message: "Variable not in scope: replace :: [Char] -> [Char] -> [Char] -> t" Commented Dec 6, 2016 at 21:16
  • 1
    What makes you expect replace to exist? Commented Dec 6, 2016 at 21:24
  • Since I'm doing it like it's done in a tutorial and they use it that way, I considered it to be part of the library I'm importing. Commented Dec 6, 2016 at 21:26
  • What tutorial? Show us. Commented Dec 6, 2016 at 21:26
  • 1
    I had a look at that tutorial, and it tells you to prepare by getting a library from here: github.com/jgoerzen/missingh. That's the library that contains replace (in Data.List.Utils), not Data.List.Split. Commented Dec 6, 2016 at 21:44

1 Answer 1

4

You cannot use let at the toplevel like you do. It is only needed while using the interpreter.

Sign up to request clarification or add additional context in comments.

3 Comments

"[Top-level let] is only needed while using the interpreter." -- And not even in that case if you are using GHC 8.
Yes of course. I somehow thought I already tried to do it in a do block but obviously I didn't try... because it works. But now I get an issure with the missing expression.
Looks like it's not the only issue I have here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.