Outline view query

Help
2005-09-21
2012-12-06
  • Mark Wassell
    Mark Wassell
    2005-09-21

    I have a Haskell file that uses the Parsec module. In outline view some of the declarations appear as  "(..) pattern binding" and some appear as "f(.) <function_name>".

    This might be more of a lack of understanding of Haskell on my part but what is the difference?

    I thought that the first refered to a declaration with a pattern on the lhs but the some functions with this in the outline view do not have a pattern on the lhs (unless you count not having anthing).

    For example I have the two declarations:

    identifier = do {
            ; whiteSpace
            ; x <- letter
            ; xs <- many ( alphaNum <|> char '_'  )
            ; whiteSpace
            ; return (x:xs) } <?> "An identifier"

    commaSep p = sepBy p $ char ','

    The first appears as a "(..) pattern binding" and the second as "f(.) commaSep"

    Thanks

    Mark

     
    • Leif Frenzel
      Leif Frenzel
      2005-09-23

      Hi Mark,

      I have a Haskell file that uses the Parsec module. In outline view some of the
      declarations appear as  "(..) pattern binding" and some appear as "f(.)
      <function_name>".

      This might be more of a lack of understanding of Haskell on my part but what
      is the difference?

      The Outline displays an (almost) exact representation of the tree that is parsed out of the code by the parser in the haskell-src package (from the GHC libs). So, run over your code this is:

      ParseOk (HsModule (SrcLoc ...)
                        (Module "Main")
                        (Just [HsEVar (UnQual (HsIdent "main"))])
                        []
                        [HsPatBind (SrcLoc ...)
                                   (HsPVar (HsIdent "identifier"))
                                   (HsUnGuardedRhs ...,
                         HsFunBind [HsMatch (SrcLoc ...)
                                            (HsIdent "commaSep")
                                            [HsPVar (HsIdent "p")]
                                            (HsUnGuardedRhs ...)
                                   ]
                        ]
              )

      (I somewhat layouted this and left out the less interesting parts.) I'd say the first one is seen as pattern binding (i.e. binding of a value), the latter as function binding. The difference is that the former binds just a value to the identifier, the latter binds a function to it (i.e. we have at least one argument on the rhs). The distinction is made in Section 4.4.3 (and subsections)
      of the Haskell report.

      (Of course I wouldn't claim that my symbols are very helpful in seeing this - I'm not so much of an artist ;-)

      Hope this helps,
      Ciao,
      Leif

       
    • Leif Frenzel
      Leif Frenzel
      2005-09-23

      Aeks, I somehow lost the quote marks, and the web interface has destroyed my layout of the parse result. Sorry for that mess :-( I hope it is nonetheless understandable what I meant ...

      Ciao,
      Leif