From 75e6f7ad181d398b818367fdc5e86b1542d1bc0a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 18 Jun 2019 23:19:23 -0400 Subject: Implemented "hole" typing. --- stdlib/source/lux/type.lux | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux index fd02c1497..15f284d10 100644 --- a/stdlib/source/lux/type.lux +++ b/stdlib/source/lux/type.lux @@ -4,9 +4,10 @@ [equivalence (#+ Equivalence)] [monad (#+ Monad do)]] [control + ["." function] + ["." exception (#+ exception:)] ["p" parser - ["s" code (#+ Parser)]] - ["." function]] + ["s" code (#+ Parser)]]] [data ["." text ("#@." monoid equivalence)] ["." name ("#@." equivalence codec)] @@ -357,8 +358,9 @@ [cursor macro.cursor valueT (macro.find-type valueN) #let [_ (log! ($_ text@compose - ":log!" " @ " (.cursor-description cursor) text.new-line - (name@encode valueN) " : " (..to-text valueT) text.new-line))]] + (name@encode (name-of ..:log!)) " @ " (.cursor-description cursor) text.new-line + "Value: " (name@encode valueN) text.new-line + " Type: " (..to-text valueT) text.new-line))]] (wrap (list (code.identifier valueN)))) (#.Right valueC) @@ -413,3 +415,14 @@ (~ (get@ #expression exemplar))} {(~ extraction) (:assume [])})))))) + +(exception: #export (hole-type {location Cursor} {type Type}) + (exception.report + ["Location" (.cursor-description location)] + ["Type" (..to-text type)])) + +(syntax: #export (:hole) + (do @ + [cursor macro.cursor + expectedT macro.expected-type] + (macro.fail (exception.construct ..hole-type [cursor expectedT])))) -- cgit v1.2.3