parsing - Haskell filter option concatenation -


exchangesymbols "a§ b$ c. 1. 2. 3/" = filter (char.isalphanum) (replacestr str " " "_") 

the code above supposed first replace "spaces" "_", filter string according char.isalphanum. unfortunately char.isalphanum part absorbs exchanged "_", isn't intention , want hold "_". so, thought nice add exception filter goes like:

exchangesymbols "a§ b$ c. 1. 2. 3/" = filter (char.isalphanum && /='_') (replacestr str " " "_") 

you see added && not /='_'. produces parse error, not possible concatenate filter options, there smart workaround ? thought wrapping filter function, 1000 times or each recursion adding new filter test (/='!'),(/='§') , on without adding (/='_'). doesn't seem handy solution.

writing

... filter (char.isalphanum && /='_') ...

is type error (the reason why yields parse error maybe used /= prefix - infix operator). cannot combine functions (&&) since operator on booleans (not on functions).

acutally code snipped should read:

... filter (\c -> char.isalphanum c && c /= '_') ...


Comments