1

I am trying to import and use the prettyprinter package. I have installed the package via stack with the following command:

stack install prettyprinter

However, I have trouble trying to import this package once I load ghci to try it. I have been taking shots in the dark, such as:

import prettyprinter

import Prettyprint

import Data.Text.Prettyprint

... and so on. Can anyone tell me the right command? Since this is just the latest of many similar experiences, I'd also like to know how I can figure out this command for myself using the information on the stackage page.

Kevin Bradner
  • 438
  • 4
  • 11
  • 1
    A package defines a set of modules, you can look up the modules, for example in [hackage](https://hackage.haskell.org/package/prettyprinter-1.3.0/docs/Data-Text-Prettyprint-Doc.html). Here the module you probably want to import is `import Data.Text.Prettyprint.Doc`. – Willem Van Onsem Jun 25 '19 at 22:02
  • 1
    Also, [you shouldn't normally use `stack install` for libraries](https://lexi-lambda.github.io/blog/2018/02/10/an-opinionated-guide-to-haskell-in-2018/#understanding-stacks-model-and-avoiding-its-biggest-gotcha). Use `stack build` instead. – bradrn Jun 26 '19 at 00:11

2 Answers2

3

Thanks to Willem Van Onsem for pointing out that I need to be importing modules, not packages. In this case, import Data.Text.Prettyprint.Doc was the appropriate choice.

Kevin Bradner
  • 438
  • 4
  • 11
0

How do you start ghci?

You shouldn't start it directly.

You may try stack exec ghci.