Jono
Jono

Reputation: 3633

Can't get Data.List functions to work in haskell

I'm building a haskell program, and I want to use the library Data.List. So at the top of my program I've addedimport Data.List and below in one of my functions I've typed Data.List.isAlpha x but it gives me a compile error - Not in scope:Data.List.isAlpha'`. Any suggestions? I've tried using another function from Data.List and that doesn't work.

Here's the function, but I've tried dumbing it down but its not working either:

myFunc:: [String] -> String

myFunc list = filter Data.List.isAlpha (Data.List.nub(concat list))

This function is taking a list of strings, nub'ing then to get rid of duplicates, and then keeping only the characters left that are letters.

Any help would be really useful! Thanks!

Upvotes: 2

Views: 5104

Answers (2)

Chris Taylor
Chris Taylor

Reputation: 47402

The function isAlpha is not in Data.List. Rather it is in Data.Char.

Upvotes: 5

daniel gratzer
daniel gratzer

Reputation: 53911

isAlpha is in Data.Char, not Data.List

 import Data.List
 import Data.Char

 myFunc :: [String] -> String
 myFunc ls = filter isAlpha . nub . concat $ ls

In the future, I'd suggest not fully qualifying names, just do

import Data.List as L
import Data.Char as C

-- Now use `C.isAlpha` and `L.nub`

And when searching for functions, I'd suggest hoogle

Upvotes: 8

Related Questions