Why don't the Data.Text examples work for me?

Viewed 2068

Here's what I tried to do in ghci:

import Data.Text
strip "  abc  "

I get this error message:

<interactive>:1:6:
    Couldn't match expected type `Text' against inferred type `[Char]'
    In the first argument of `strip', namely `"  abc  "'
    In the expression: strip "  abc  "
    In the definition of `it': it = strip "  abc  "

I was expecting this to work because it was given on many web pages including this answer: In Haskell, how do you trim whitespace from the beginning and end of a string?

What am I doing wrong?

3 Answers
{-# OPTIONS_GHC -fwarn-missing-signatures #-}
{-# LANGUAGE OverloadedStrings #-}

import Data.Text as MJ

main :: IO()
main = do

      print $ strip $ pack "  abc  "
      print  $ MJ.intercalate "as" ["1","2","3"]
Related