Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse Span defined in pretty #1

Closed
harpocrates opened this issue Dec 29, 2016 · 1 comment
Closed

Reuse Span defined in pretty #1

harpocrates opened this issue Dec 29, 2016 · 1 comment

Comments

@harpocrates
Copy link
Owner

The project already has a dependency on pretty for pretty-printing. In Text.PrettyPrint.Annotated.HughesPJ, there is

data Span a = Span
                  { spanStart      :: !Int
                   , spanLength     :: !Int
                   , spanAnnotation :: a
                   } deriving (Show,Eq)

Which might be a good candidate as the output tag type for parsing. Some thoughts on this:

  • One uniform Span data type for both pretty-printing and parsing is slick, especially a reused one.

  • I'm not sure I see any use for spanAnnotation with parsing - maybe a means of plugging in more helpful information about position. For the latter, one would probably define

    data Pos = Pos { row :: !Int, col :: !Int } deriving (Eq, Ord)
    type ParseSpan = Span Pos
    

    then parsing functions would produce things of type Expr ParseSpan, Ty ParseSpan, etc.

All changes would be in the Parser module, just returning this type.

@harpocrates
Copy link
Owner Author

harpocrates commented Jan 16, 2017

Given that as of #5 we are now using wl-pprint-annotated which doesn't have Span (it doesn't bother to define such a type), this is no longer on the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant