Skip to content

Simplify the label syntax #1

@tim-m89

Description

@tim-m89

The labels in Salsa are handled like the following:

-- Type level label
data WriteLine_  
-- Term level label             
_WriteLine                     = undefined :: WriteLine_
-- Functions for invoking methods with '#'
_writeLine args target = invoke target _WriteLine args
_writeLine_ target = invoke target _WriteLine ()

This could ideally be simplified. Upper case labels (the most common convention in .net) can be supported on both the type level and term level by simply:

data WriteLine = WriteLine 

Lower case (allowed in .Net as far as I know) can supported on the term level easily enough using the undefined notation though not on the type level. This is probably ok to give it some arbitrary prefix since these are very uncommon by convention:

data X_foo
foo = undefined :: X_foo

As for the invoke wrappers, these could potentially be dropped if the use of '#' as in infix operator in it's current form is not continued. The problem is that we would end up having:

Console # WriteLine "hello"

which really means:

Console # (WriteLine "hello")

Since we can't bind higher than function application, and end up trying to come up with a quick solution:

Console # WriteLine $ "hello"

Though this might not be the ideal solution. Maybe a tuple should be used, but at which end is this to be? From an oop straight from .Net perspective, the object method arg syntax does have merit. On the other hand, it feels some what more natural in a functional setting to to treat the function/method as more first class, i.e.

WriteLine # (Console, "hello")

Finally, without the invoke wrappers and changing the meaning of '#' to be more than reverse application, means that we may need 2 or more operators for both static and instance invocation (though cannot confirm). Any thoughts on syntax are greatly appreciated..

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions