-1

I am trying to find the type of privacyContents in

privacyContents <- LazyIO.readFile $ markdownPath ++ "PRIVACY.md"

Is the type of this variable defined by the return type of LazyIO.readFile? And if the answer is yes, what is the return type of LazyIO.readFile?

arrowd
  • 33,231
  • 8
  • 79
  • 110
Mia.M
  • 97
  • 1
  • 1
  • 8
  • 1
    What is `LazyIO`? – arrowd Aug 26 '16 at 16:13
  • 2
    You should tell us what imports are in scope - in particular, what module is `LazyIO` an alias for? – ErikR Aug 26 '16 at 16:13
  • `LazyIO` could plausibly be `Data.Text.Lazy.IO` or it could be `Data.ByteString.Lazy` or it could be something completely different. Who knows? – Dietrich Epp Aug 26 '16 at 16:18
  • `:t LazyIO.readfile $ markdownPath ++ "PRIVACY.md"` should indicate that the type is `m something` for some monad `m`, in which case `privacyContents` would have type `something`. – chepner Aug 26 '16 at 16:18
  • From my understanding, LazyIO is a package. [link](http://hackage.haskell.org/package/lazyio) And the import in scope should be `import qualified Data.Text.Lazy.IO as LazyIO` – Mia.M Aug 28 '16 at 00:45

1 Answers1

3

You can have GHC tell you what the type is by using a type hole.

Just add a let statement after the assignment:

...
privacyContents <- LazyIO.readFile $ markdownPath ++ "PRIVACY.md"
let _ = privacyContents :: _
...

When you compile the program or load it into ghci you will be told what the type of privacyContents is.

My guess is that LazyIO correpsonds to Data.Text.IO.Lazy which would make privacyContents a lazy Text value (i.e. type Data.Text.Lazy.Text).

ErikR
  • 51,541
  • 9
  • 73
  • 124
  • I tried to use `Data.Text.Lazy.Text` as the type of the variable, but error `Not in scope: type constructor or class ‘Data.Text.Lazy.Text’` was returned when I compiled the program. – Mia.M Aug 28 '16 at 01:57
  • Did you `import Data.Text.Lazy`? – ErikR Aug 28 '16 at 02:01
  • Yes, I think I did as `import qualified Data.Text.Lazy.IO as LazyIO` – Mia.M Aug 28 '16 at 02:39
  • But did you import Data.Text.Lazy? That is a different module from Data.Text.Lazy.IO. If you are still having trouble you should post a new question. – ErikR Aug 28 '16 at 04:01
  • I see. I didn't import it at the first time. I just did right now. It seemed to work now. Thanks a lot! – Mia.M Aug 31 '16 at 11:14