Definition dependency analysis
tricu now allows defining terms in any order and will resolve dependencies to ensure that they're evaluated in the right order. Undefined terms are detected and throw errors during dependency ordering. For now we can't define top-level mutually recursive terms.
This commit is contained in:
		
							
								
								
									
										60
									
								
								lib/base.tri
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								lib/base.tri
									
									
									
									
									
								
							| @ -18,9 +18,9 @@ y = ((\mut wait fun : wait mut (\x : fun (wait mut x))) | ||||
| triage = \leaf stem fork : t (t leaf stem) fork | ||||
| test   = triage "Leaf" (\_ : "Stem") (\_ _ : "Fork") | ||||
|  | ||||
| matchBool = (\ot of : triage  | ||||
|   of  | ||||
|   (\_ : ot)  | ||||
| matchBool = (\ot of : triage | ||||
|   of | ||||
|   (\_ : ot) | ||||
|   (\_ _ : ot) | ||||
| ) | ||||
|  | ||||
| @ -35,44 +35,44 @@ emptyList? = matchList true (\_ _ : false) | ||||
| head = matchList t (\head _ : head) | ||||
| tail = matchList t (\_ tail : tail) | ||||
|  | ||||
| lconcat = y (\self : matchList  | ||||
|   (\k : k)  | ||||
| lconcat = y (\self : matchList | ||||
|   (\k : k) | ||||
|   (\h r k : pair h (self r k))) | ||||
|  | ||||
| lAnd = (triage  | ||||
|   (\_     : false)  | ||||
|   (\_ x   : x)  | ||||
| lAnd = (triage | ||||
|   (\_     : false) | ||||
|   (\_ x   : x) | ||||
|   (\_ _ x : x)) | ||||
|  | ||||
| lOr = (triage  | ||||
|   (\x     : x)  | ||||
|   (\_ _   : true)  | ||||
| lOr = (triage | ||||
|   (\x     : x) | ||||
|   (\_ _   : true) | ||||
|   (\_ _ _ : true)) | ||||
|  | ||||
| map_ = y (\self :  | ||||
|   matchList  | ||||
|     (\_ : t)  | ||||
| map_ = y (\self : | ||||
|   matchList | ||||
|     (\_ : t) | ||||
|     (\head tail f : pair (f head) (self tail f))) | ||||
| map = \f l : map_ l f | ||||
|  | ||||
| equal? = y (\self : triage  | ||||
|   (triage  | ||||
|     true  | ||||
|     (\_   : false)  | ||||
|     (\_ _ : false))  | ||||
|   (\ax :  | ||||
|     triage  | ||||
|       false  | ||||
|       (self ax)  | ||||
|       (\_ _ : false))  | ||||
|   (\ax ay :  | ||||
|     triage  | ||||
|       false  | ||||
|       (\_ : false)  | ||||
| equal? = y (\self : triage | ||||
|   (triage | ||||
|     true | ||||
|     (\_   : false) | ||||
|     (\_ _ : false)) | ||||
|   (\ax : | ||||
|     triage | ||||
|       false | ||||
|       (self ax) | ||||
|       (\_ _ : false)) | ||||
|   (\ax ay : | ||||
|     triage | ||||
|       false | ||||
|       (\_ : false) | ||||
|       (\bx by : lAnd (self ax bx) (self ay by)))) | ||||
|  | ||||
| filter_ = y (\self : matchList  | ||||
|   (\_ : t)  | ||||
| filter_ = y (\self : matchList | ||||
|   (\_ : t) | ||||
|   (\head tail f : matchBool (t head) i (f head) (self tail f))) | ||||
| filter  = \f l : filter_ l f | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 James Eversole
						James Eversole