[Haskell-cafe] need help with syntax...

Daryoush Mehrtash dmehrtash at gmail.com
Tue Dec 7 01:26:53 CET 2010

I am having hard time understanding the following code.  The code is from
Applicative Parser library:

 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)
                                    (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 [])


Fail [msg] [*ins*]

Appreciate any help.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20101206/3973bb61/attachment.htm>

More information about the Haskell-Cafe mailing list