need help with syntax...

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/s... 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

On 12/6/10 7:26 PM, Daryoush Mehrtash wrote:
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/s...
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 = ...1 del exp = ...2 in case tts of (t:ts) -> if p t then ...3 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
The let expressions are binding functions so ins names (\exp -> ...1) and del names (\exp -> ...2). Thus, when del_ok is true we get, Fail [msg] (ins : if del_ok then [del] else []) == Fail [msg] (ins : if del_ok then del : [] else []) == Fail [msg] (ins : del : []) == Fail [msg] ((\exp -> ...1) : (\exp -> ...2) : []) and when del_ok is false we get Fail [msg] ((\exp -> ...1) : []) -- Live well, ~wren
participants (2)
-
Daryoush Mehrtash
-
wren ng thornton