Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not in scope: `fromMaybe' - haskell

I have a string and a list lst of string and I should return nothing if the lst does not contains the given string or just list' where list' is identic to the lst except that the first occurene of the given string removed.

allExcept :: [Char] -> [[Char]] -> Maybe [[Char]]

allExcept ch1 chars 
   | ch1  `notElem` chars = Nothing

allExcept ch [] = []      
allExcept ch (x:xs)
  | ch /= x = Just(x:(fromJust(allExcept ch xs)))
  | otherwise = Just(xs)  

the result of my code is : Not in scope: `fromMaybe'

like image 527
kam kimo Avatar asked Sep 18 '15 10:09

kam kimo


1 Answers

You need to import the Data.Maybe module:

import Data.Maybe
like image 121
Emil Vikström Avatar answered Oct 20 '22 19:10

Emil Vikström