[Haskell-beginners] mayBe stuck

prad prad at towardsfreedom.com
Thu Aug 5 18:22:35 EDT 2010

i'm trying to create my own split function with % as delimiter.
so i have
eqD = (=='%')

and send 

    let s = "zaoeu%aeuasnt%staashaeu%nthdanoe%nthd"
    putStrLn $ show $ brS (findIndex eqD s) s 

to a function brS:

brS i ss
    | isNothing i   = ss
    | otherwise     = (take i ss) : (brS newIndex newStr)
                            newIndex    = findIndex eqD newStr
                            newStr      = drop (i+1) ss

but get the following error:

    Couldn't match expected type `Maybe a' against inferred type `Int'
    In the first argument of `isNothing', namely `i'
    In the expression: isNothing i :: mayBe a
    In a stmt of a pattern guard for
                 the definition of `brS':
          isNothing i :: mayBe a

my understanding is that i need the isNothing because findIndex will
return Just Int or Nothing.

however, i'm not sure how to resolve what seems to me to be an issue
between a Maybe and an Int.

In friendship,

                                      ... with you on your journey
Towards Freedom
http://www.towardsfreedom.com (website)
Information, Inspiration, Imagination - truly a site for soaring I's

More information about the Beginners mailing list