Sorry didn't read that properly. Hold on.<br>-deech<br><br><div class="gmail_quote">On Thu, Aug 5, 2010 at 5:31 PM, aditya siram <span dir="ltr"><<a href="mailto:aditya.siram@gmail.com">aditya.siram@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">This is happening because findIndex has the signature:<br><a href="http://hackage.haskell.org/packages/archive/haskell98/latest/doc/html/List.html#v:findIndex" title="Score: 93.86667" target="_blank">findIndex</a>
:: (a -> Bool) -> [a] -> Maybe
Int<br><br>From this we know that 'findIndex' can return a 'Just Int' or 'Nothing'.<br><br>GHC is telling you that you need to handle the case where the list element you ask for does not exist and findIndex returns 'Nothing'. <br>
<br>The functions in the Maybe module [1]may be of some help here.<br><br>-deech<br><br>[1] <a href="http://hackage.haskell.org/packages/archive/haskell98/latest/doc/html/Maybe.html" target="_blank">http://hackage.haskell.org/packages/archive/haskell98/latest/doc/html/Maybe.html</a><div>
<div></div><div class="h5"><br>
<br><div class="gmail_quote">On Thu, Aug 5, 2010 at 5:22 PM, prad <span dir="ltr"><<a href="mailto:prad@towardsfreedom.com" target="_blank">prad@towardsfreedom.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
i'm trying to create my own split function with % as delimiter.<br>
so i have<br>
eqD = (=='%')<br>
<br>
and send<br>
<br>
let s = "zaoeu%aeuasnt%staashaeu%nthdanoe%nthd"<br>
putStrLn $ show $ brS (findIndex eqD s) s<br>
<br>
to a function brS:<br>
<br>
brS i ss<br>
| isNothing i = ss<br>
| otherwise = (take i ss) : (brS newIndex newStr)<br>
where<br>
newIndex = findIndex eqD newStr<br>
newStr = drop (i+1) ss<br>
<br>
but get the following error:<br>
<br>
Couldn't match expected type `Maybe a' against inferred type `Int'<br>
In the first argument of `isNothing', namely `i'<br>
In the expression: isNothing i :: mayBe a<br>
In a stmt of a pattern guard for<br>
the definition of `brS':<br>
isNothing i :: mayBe a<br>
<br>
<br>
my understanding is that i need the isNothing because findIndex will<br>
return Just Int or Nothing.<br>
<br>
however, i'm not sure how to resolve what seems to me to be an issue<br>
between a Maybe and an Int.<br>
<br>
<br>
<br>
--<br>
In friendship,<br>
prad<br>
<br>
... with you on your journey<br>
Towards Freedom<br>
<a href="http://www.towardsfreedom.com" target="_blank">http://www.towardsfreedom.com</a> (website)<br>
Information, Inspiration, Imagination - truly a site for soaring I's<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br>
</div></div></blockquote></div><br>