Frage

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!

War es hilfreich?

Lösung

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

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top