Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top