I am having hard time understanding the following code.  The code is from Applicative Parser library:  http://hackage.haskell.org/packages/archive/uu-parsinglib/2.5.5.2/doc/html/src/Text-ParserCombinators-UU-BasicInstances.html

 instance (Show a,  loc `IsLocationUpdatedBy` a) => Provides  (Str  a loc)  (a -> Bool, String, a)  a where
 splitState (p, msg, a) k (Str tts msgs pos del_ok)
= let ins exp = (5, k a (Str tts (msgs ++ [Inserted (show a) pos exp]) pos False))
del exp = (5, splitState (p,msg, a)
k
(Str (tail tts)
(msgs ++ [Deleted (show(head tts)) pos exp])
(advance pos (head tts))
True ))
in case tts of
(t:ts) -> if p t
then show_symbol ("Accepting symbol: " ++ show t ++ " at position: " ++ show pos ++"\n")
(Step 1 (k t (Str ts msgs (advance pos t) True)))
else Fail [msg] (ins: if del_ok then [del] else [])
[] -> Fail [msg] [ins]




Specifically I am having hard time understanding how the "ins exp" and "del exp" in the "let" is related to "ins:"  "del_ok", [del], [ins].
I don't understand how given the "let" expression the following expressions are expanded

 Fail [msg] (ins: if del_ok then [del] else [])

and

Fail [msg] [ins]

Appreciate any help.


Thanks

Daryoush