Commits

Brian McKenna committed 938789c

Get website examples working

Had to update unification to unify row objects with non-polymorphic
objects on either side. We were previously biased because we should
probably be safe about widening via instantiation. Urgh.

YOLO

Comments (0)

Files changed (8)

examples/ajaxmonad.roy

     $.get x.url x.payload f
 }
 
-let v = (do ajaxRequest
+let v = (do ajaxRequest.bind
   value <- {url: '/examples/helloworld.roy', payload: 'stuff'}
   console.log value
-  return value
+  ajaxRequest.return value
 )
 
 console.log v

examples/data.roy

 data Maybe a =
-  Some a | None
+  Some #a | None
 
 let none = None ()
 
 printSomething none
 
 data Either a b =
-  Left a | Right b
+  Left #a | Right #b
 
 let printString (s: String) =
   console.log s
 console.log (getBool (True ()) 1 2)
 console.log (getBool (False ()) 1 2)
 
-data MyList a = Empty | Many a (MyList a)
+data MyList a = Empty | Many #a (MyList #a)
 
 let empty = Empty ()
 console.log (Many true (Many true empty))

examples/deferredmonad.roy

   bind: \x f -> x.pipe f
 }
 
-let v = do deferred
+let v = do deferred.bind
   hello <- $.ajax 'examples/helloworld.roy'
   alias <- $.ajax 'examples/alias.roy'
-  return (hello ++ alias)
+  deferred.return (hello ++ alias)
 
 v.done console.log

examples/option.roy

     case None = None ()
 }
 
-console.log (do optionMonad
+console.log (do optionMonad.bind
   x <- Some 1
   let y = 2
   z <- Some 3
-  return x + y + z
+  optionMonad.return x + y + z
 )

examples/structural.roy

 } with {
   target: "World"
 })
-
-export obj

examples/tracemonad.roy

     f x
 }
 
-console.log (do traceMonad
+console.log (do traceMonad.bind
   w <- 1
   let x = 2
   y <- 3
   z <- 4
-  return w + x + y + z
+  traceMonad.return w + x + y + z
 )

examples/types.roy

 // console.log "40" + 2
 
 // Explicit
-let f x: Number = x
+let f (x: Number) = x
 
 console.log (f 100)
 

src/typeinference.js

                 }, accum);
             }, {});
         })(a, [], []);
+    } else if(a instanceof t.ObjectType && b instanceof t.RowObjectType) {
+        return mostGeneralUnifier(b, a);
     } else if(a instanceof t.ArrayType && b instanceof t.ArrayType) {
         return mostGeneralUnifier(a.type, b.type);
     } else if(a instanceof t.TagType && b instanceof t.TagType && a.name == b.name && a.vars.length == b.vars.length) {