Skip to content

Commit

Permalink
Support the type literal syntax with type variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nihei9 committed Jan 1, 2023
1 parent 216f92a commit 48ccf1b
Show file tree
Hide file tree
Showing 22 changed files with 208 additions and 89 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ ok = f.Maybe().BallpointPen().OK() // false

:eyes: `Fields` method isn't available in `FountainPen` because it has no fields.

#### Example: Generics
#### Example: Generics #1

You can define polymorphic types using type variables.

##### In Ino

Type variables can follow a data type name.
Type variables can follow a data type name. In this example, `a` is a type variable.

```
data Option a
Expand All @@ -99,3 +99,14 @@ num, ok := s1.Maybe().Some().Fields() // 100, true
opt, ok := s2.Maybe().Some().Fields() // Some("Hello"), true
str, ok := opt.Maybe().Some().Fields() // "Hello", true
```

#### Example: Generics #2

Polymorphic-type literals must be enclosed in parentheses.

```
data List a
= Nil
| Cons a (List a)
;
```
19 changes: 14 additions & 5 deletions code/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,23 @@ func genValConsDecl(d *ir.ValConsDecl) ([]ast.Decl, error) {
return f.Decls, nil
}

func genType(ty ir.Type) (ast.Expr, error) {
func genType(ty ir.Type) (string, error) {
switch t := ty.(type) {
case *ir.BasicType:
return ast.NewIdent(t.Name), nil
return t.Name, nil
case *ir.NamedType:
return ast.NewIdent(t.Name), nil
if len(t.TypeVars) == 0 {
return t.Name, nil
}
var b strings.Builder
fmt.Fprintf(&b, "%v[T%v", t.Name, t.TypeVars[0])
for _, v := range t.TypeVars[1:] {
fmt.Fprintf(&b, ", T%v", v)
}
fmt.Fprintf(&b, "]")
return b.String(), nil
case *ir.TypeVar:
return ast.NewIdent("T" + strconv.Itoa(t.Num)), nil
return "T" + strconv.Itoa(t.Num), nil
}
return nil, fmt.Errorf("invalid type: %T", ty)
return "", fmt.Errorf("invalid type: %T", ty)
}
3 changes: 2 additions & 1 deletion ir/ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type BasicType struct {
}

type NamedType struct {
Name string
Name string
TypeVars []int
}

type TypeVar struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/ino-report.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion parser/ino.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"ino","lexical":{"initial_mode_id":1,"mode_names":["","default"],"kind_names":["","ws","nl","def","or","semicolon","kw_data","id"],"kind_ids":[null,[0,1,2,3,4,5,6,7]],"compression_level":2,"specs":[null,{"kind_names":["","ws","nl","def","or","semicolon","kw_data","id"],"push":[0,0,0,0,0,0,0,0],"pop":[0,0,0,0,0,0,0,0],"dfa":{"initial_state_id":1,"accepting_states":[0,0,1,2,7,7,7,6,7,3,4,5],"row_count":12,"col_count":256,"transition":{"unique_entries":{"original_row_count":8,"original_col_count":256,"empty_value":0,"entries":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,5,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,6,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8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,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],"row_displacement":[0,339,341,343,0,75,150,225]},"row_nums":[0,1,2,3,4,5,6,7,7,0,0,0],"original_row_count":12,"original_col_count":256,"empty_value":0}}}]},"syntactic":{"action":[0,0,0,0,0,0,0,0,-5,0,0,1,0,0,0,0,0,0,0,0,0,20,0,0,-7,0,0,0,0,0,0,4,0,0,4,0,0,0,0,0,0,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-8,0,2,0,0,0,0,0,0,0,0,0,19,0,0,0,0,0,0,-5,0,0,9,0,0,9,9,0,0,0,-12,0,3,0,0,3,0,0,0,0,0,0,20,0,0,-15,20,0,0,0,-12,0,0,0,0,8,8,0,0,0,8,0,10,0,0,10,10,0,0,0,10,0,0,0,0,7,7,0,0,0,7,0,0,0,0,0,-16,0,0,0,0,0,19,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,-19,0,0,0,0,0,0,-20,-21,0,0,0,0,0,0,0,0,12,12,0,0,0,18,0,0,18,0,18,18,0,-25,0,0,0,0,0,0,0,0,0,-19,0,6,0,0,6,0,0,0,0,0,0,16,0,0,16,0,16,16,0,16,0,17,0,0,17,0,17,17,0,-25,0,20,0,0,-15,0,20,20,0,0,0,14,0,0,14,0,14,14,0,14,0,0,0,0,0,0,11,11,0,0,0,15,0,0,15,0,15,15,0,15,0,13,0,0,13,0,13,13,0,0],"goto":[0,0,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,23,24,0,0,0,0,0,0,0,0,0,0,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"state_count":29,"initial_state":0,"start_production":1,"lhs_symbols":[0,1,2,3,3,4,5,6,6,6,7,8,8,9,10,11,11,12,12,13,13],"alternative_symbol_counts":[0,1,2,3,1,1,7,2,1,0,1,3,1,3,1,2,1,1,0,1,0],"terminals":["","\u003ceof\u003e","error","ws","nl","def","or","semicolon","kw_data","id"],"terminal_count":10,"terminal_skip":[0,0,0,1,0,0,0,0,0,0],"kind_to_terminal":[0,3,4,5,6,7,8,9],"non_terminals":["","root'","root","decls","decl","data","ty_vars","ty_var","conss","cons","type_lit","type_lits","opt_type_lits","opt_nl"],"non_terminal_count":14,"eof_symbol":1,"error_symbol":2,"error_trapper_states":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"recover_productions":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"ast_action":{"entries":[null,null,[1],[-1,3],null,null,[2,3,6],[-1,2],null,null,null,[-1,3],null,[1,2],null,[-1,2],null,null,null,null,null]}}
{"name":"ino","lexical":{"initial_mode_id":1,"mode_names":["","default"],"kind_names":["","ws","nl","def","or","semicolon","l_paren","r_paren","kw_data","id"],"kind_ids":[null,[0,1,2,3,4,5,6,7,8,9]],"compression_level":2,"specs":[null,{"kind_names":["","ws","nl","def","or","semicolon","l_paren","r_paren","kw_data","id"],"push":[0,0,0,0,0,0,0,0,0,0],"pop":[0,0,0,0,0,0,0,0,0,0],"dfa":{"initial_state_id":1,"accepting_states":[0,0,1,2,9,9,9,8,9,3,4,5,6,7],"row_count":14,"col_count":256,"transition":{"unique_entries":{"original_row_count":8,"original_col_count":256,"empty_value":0,"entries":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,5,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,6,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,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-1,-1,-1,-1],"row_displacement":[0,339,341,343,0,75,150,225]},"row_nums":[0,1,2,3,4,5,6,7,7,0,0,0,0,0],"original_row_count":14,"original_col_count":256,"empty_value":0}}}]},"syntactic":{"action":[0,0,0,0,0,0,0,0,0,0,-5,0,0,1,0,0,0,0,0,0,0,0,0,0,0,21,0,0,-7,0,0,0,0,0,0,0,0,4,0,0,4,0,0,0,0,0,0,0,0,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-8,0,2,0,0,0,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,-5,0,0,9,0,0,9,9,0,0,0,0,0,-12,0,3,0,0,3,0,0,0,0,0,0,0,0,21,0,0,-15,21,0,0,0,0,0,-12,0,0,0,0,8,8,0,0,0,8,0,8,0,10,0,0,10,10,10,10,10,10,0,10,0,0,0,0,7,7,0,0,0,7,0,7,0,0,0,0,0,-16,0,0,0,0,0,0,0,20,0,0,20,20,20,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-19,0,0,0,0,0,0,-20,-21,0,0,0,0,0,0,0,0,0,0,12,12,0,0,0,0,0,19,0,0,19,0,19,19,-25,0,0,-26,0,0,0,0,0,0,0,0,0,0,0,-19,0,6,0,0,6,0,0,0,0,0,0,0,0,17,0,0,17,0,17,17,17,0,0,17,0,18,0,0,18,0,18,18,-25,0,0,-26,0,21,0,0,-15,0,21,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-30,0,14,0,0,14,0,14,14,14,0,0,14,0,0,0,0,0,0,11,11,0,0,0,0,0,16,0,0,16,0,16,16,16,0,0,16,0,13,0,0,13,0,13,13,0,0,0,0,0,9,0,0,9,0,9,9,9,9,0,-12,0,0,0,0,0,0,0,0,0,-32,0,-12,0,15,0,0,15,0,15,15,15,0,0,15],"goto":[0,0,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,23,24,0,0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,11,0,0,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"state_count":33,"initial_state":0,"start_production":1,"lhs_symbols":[0,1,2,3,3,4,5,6,6,6,7,8,8,9,10,10,11,11,12,12,13,13],"alternative_symbol_counts":[0,1,2,3,1,1,7,2,1,0,1,3,1,3,1,4,2,1,1,0,1,0],"terminals":["","\u003ceof\u003e","error","ws","nl","def","or","semicolon","l_paren","r_paren","kw_data","id"],"terminal_count":12,"terminal_skip":[0,0,0,1,0,0,0,0,0,0,0,0],"kind_to_terminal":[0,3,4,5,6,7,8,9,10,11],"non_terminals":["","root'","root","decls","decl","data","ty_vars","ty_var","conss","cons","type_lit","type_lits","opt_type_lits","opt_nl"],"non_terminal_count":14,"eof_symbol":1,"error_symbol":2,"error_trapper_states":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"recover_productions":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"ast_action":{"entries":[null,null,[1],[-1,3],null,null,[2,3,6],[-1,2],null,null,null,[-1,3],null,[1,2],null,[2,3],[-1,2],null,null,null,null,null]}}
5 changes: 5 additions & 0 deletions parser/ino.vartan
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cons
;
type_lit
: id
| l_paren id ty_vars r_paren #ast id ty_vars
;
type_lits
: type_lits type_lit #ast type_lits... type_lit
Expand All @@ -54,6 +55,10 @@ or
: '|';
semicolon
: ';';
l_paren
: '(';
r_paren
: ')';
kw_data
: 'data';
id
Expand Down
32 changes: 22 additions & 10 deletions parser/ino_lexer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 48ccf1b

Please sign in to comment.