Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

[WIP] Tree decl #22

Closed
wants to merge 3 commits into from
Closed

[WIP] Tree decl #22

wants to merge 3 commits into from

Conversation

mxswd
Copy link
Contributor

@mxswd mxswd commented Aug 24, 2013

⚠️ Still working out the details ⚠️

Don't bother examining the details.

But the idea is:

data Declaration :: * -> * where
    DecNode :: k -> Identifier -> DecFNode -> [Declaration k] -> Declaration k
    DecLeaf :: k -> Identifier -> DecFLeaf                    -> Declaration k

Then in Clang.hs instead of

Just $ TypeAlias (Identifier $ getCursorSpelling c) (Type "foobar")

You can do

Just $ DecLeaf comment (Identifier $ getCursorSpelling c) (TypeAlias (Type "foobar"))

But if you used a Class instead of a TypeAlias it would be a TYPE ERROR™ (Because a Class can not be a leaf, it has contents inside of it).
MAGIC

@mxswd
Copy link
Contributor Author

mxswd commented Aug 24, 2013

I've got to rebase onto the new HEAD.
But that is a job for tomorrow.

-- | forall . k
data Declaration :: * -> * where
DecNode :: k -> Identifier -> DecFNode -> [Declaration k] -> Declaration k
DecLeaf :: k -> Identifier -> DecFLeaf -> Declaration k
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what you mean by:

It is expressible as not a GADT, but it is misleading what the forall is, so I don't write them that way

oh and originally it was any type of content, so it was existensial, so it was a GADT. But restricting it is better

I like the GADT syntax, but I'm not sure how k is restricted at all here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah what I meant was, originally, the DecFNode and DecFLeaf were both free in the for all, and their type didn't appear in the kind signature. But because we know something about the structure of it, we can have those 2 types set.

On 25/08/2013, at 4:33 AM, Justin Spahr-Summers notifications@github.com wrote:

In Text/Documentalist/SourceParser.hs:

-data Declaration = Class Identifier SuperTypes [Declaration] -- ^ A class declaration.

  •             | Interface Identifier SuperTypes [Declaration]        -- ^ An abstract interface, or Objective-C protocol definition.
    
  •             | Mixin Identifier Type [Declaration]                  -- ^ A mixin, or Objective-C category declaration.
    
  •             | Property Identifier UnderlyingType                   -- ^ A property declaration in a class.
    
  •             | Enumeration Identifier UnderlyingType [Declaration]  -- ^ An enumeration.
    
  •             | Constant Identifier UnderlyingType                   -- ^ A constant within an enumeration or class, or outside of any scope.
    
  •             | Function Identifier ResultTypes [Declaration]        -- ^ A function.
    
  •             | ClassMethod Identifier ResultTypes [Declaration]     -- ^ A class method or static member function.
    
  •             | InstanceMethod Identifier ResultTypes [Declaration]  -- ^ An instance method or member function.
    
  •             | Parameter Identifier UnderlyingType                  -- ^ The parameter to a function or method.
    
  •             | TypeAlias Identifier Type                            -- ^ A redeclaration of a type under a different name.
    
  •             deriving (Eq, Ord, Show)
    
    +-- | forall . k
    +data Declaration :: * -> * where
  • DecNode :: k -> Identifier -> DecFNode -> [Declaration k] -> Declaration k
  • DecLeaf :: k -> Identifier -> DecFLeaf -> Declaration k
    Could you explain what you mean by:

It is expressible as not a GADT, but it is misleading what the forall is, so I don't write them that way

oh and originally it was any type of content, so it was existensial, so it was a GADT. But restricting it is better

I like the GADT syntax, but I'm not sure how k is restricted at all here.


Reply to this email directly or view it on GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k is a forall, any type of Comment can be used.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jspahrsummers
Copy link
Owner

@maxpow4h By the way, I'd prefer merging over rebasing for published branches. It's easy to see conflict resolution that way, and it doesn't break anyone's checked-out copies of the branch.

@mxswd
Copy link
Contributor Author

mxswd commented Aug 25, 2013

Sure thing.

@mxswd
Copy link
Contributor Author

mxswd commented Aug 25, 2013

This branch is going away now.
decl-functor supersedes it.

@mxswd mxswd closed this Aug 25, 2013
@mxswd mxswd deleted the tree-decl branch August 27, 2013 08:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants