From e5625dd840a8b8adc76987f649da254335d3d93a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 11 Aug 2022 16:50:42 -0400 Subject: Improved exception-definition macro. --- licentia/source/program/licentia/input.lux | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'licentia/source/program') diff --git a/licentia/source/program/licentia/input.lux b/licentia/source/program/licentia/input.lux index afc723656..f1166d865 100644 --- a/licentia/source/program/licentia/input.lux +++ b/licentia/source/program/licentia/input.lux @@ -4,7 +4,7 @@ [abstract [monad (.only do)]] [control - ["[0]" exception (.only exception)] + ["[0]" exception (.only Exception)] ["<>" parser]] [data [text @@ -38,13 +38,15 @@ (.field "name" .string) (.field "version" .string)))) -(exception .public (cannot_use_fractional_amount [amount Frac]) - (exception.report - (list ["Amount" (%.frac amount)]))) +(with_template [ ] + (exception.def .public (cannot_use_fractional_amount it) + (Exception ) + (exception.report + (list ["Amount" ( it)]))) -(exception .public (cannot_use_negative_amount [amount Int]) - (exception.report - (list ["Amount" (%.int amount)]))) + [cannot_use_fractional_amount Frac %.frac] + [cannot_use_negative_amount Int %.int] + ) (def amount (Parser Nat) @@ -58,7 +60,8 @@ (i.> +0 amountI))] (wrap (.nat amountI)))) -(exception .public (invalid_period [period (Period Nat)]) +(exception.def .public (invalid_period period) + (Exception (Period Nat)) (exception.report (list ["Start" (%.nat (the time.#start period))] ["End" (%.nat (the time.#end period))]))) -- cgit v1.2.3