case i of Just i -> let z = splitAt i lst x = fst z y = (snd z) in init x x ++ newNmr x ++ y
Nothing -> [5]
If I understand what you are trying to do correctly, a more idiomatic (and syntactically correct code) would be:
case elemIndex toReplace lst of
Just i -> let (xs,_:ys)=splitAt i lst in xs ++ (newNmr:ys)
_ -> [5]
In more general terms, replacing individual elements in standard lists is a very inefficient operation for large lists. Having you considered using a Zipper List which allows you to efficiently replace elements at a focal point (and also to traverse the list forward and backward efficiently)?