[Grace-core] Aside from Abstract

James Noble kjx at ecs.vuw.ac.nz
Tue Nov 5 23:11:29 PST 2013


> That could work.  How would we restrict what items could go into a variant type if EmptyList is just an object?

I'm not sure I see the problem.

emptyList is an object.  EmptyList is a type that matches / describes / permits only emptylist.
assuming singleton / Singleton is not overridden then we should be OK, I think. 

remember that things like 1 and "foo" are singletons / autozygotic


match (42) 
  case { "a" -> print "ay" }
  case { 1 -> print "ONE" }
  case { _ -> print "else" } 
  
  
(but not booleans because otherwise it's too easy to confuse a | b vs a || b ...) 

>  Is it sufficient that it just have a match method?

probably not - the match method's semantics must be sensible. 

>  That could be reasonable (e.g. with Number), but I worry somebody might forget to wrap the value with singleton and end up with a weird match that doesn't correspond to our interpretation of this as a type (not just a pattern).

right. so just inheriting from Singleton or defining the method probably isn't enough.
We probably need a "marker annotation" somewhere or something that gives a promise
to the static type system that everything is behaving as it should

J


More information about the Grace-core mailing list