klappvisor
klappvisor

Reputation: 1099

Not in scope: ‘<>’ for Data.Text

I'm trying to join two Data.Text using <> operator, but when I compile I see the following error:

Not in scope: ‘<>’
    Perhaps you meant one of these:
      ‘<*>’ (imported from Prelude), ‘>>’ (imported from Prelude),
      ‘<=’ (imported from Prelude)

I use GHC 7.10.3, but according to this answer it was added long ago.

Probably there is already answer to that question, but it's very hard to find it on StackOverflow due to <> symbols.

Could you please help?

Upvotes: 2

Views: 300

Answers (1)

leftaroundabout
leftaroundabout

Reputation: 120711

Whenever the compiler complains that some function isn't in scope, there's a good chance that you've just forgotten to import it. Your first stop at such an occasion should be Hayoo, which will readily tell you that <> is defined in the module Data.Monoid from the base library. So you just need to

import Data.Monoid ((<>))

on top of your module. Actually that's such a common module that I'd pretty much always import it, just as

import Data.Monoid

If something isn't in base, you may also need to install the package it is in / add it as a dependency to the .cabal file.

Upvotes: 4

Related Questions