From: Mart Lubbers Date: Fri, 5 Oct 2018 09:12:51 +0000 (+0200) Subject: gopdt X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=9c069628612d9cc4198d3a88036d68f653fa9cb6;p=clean-tests.git gopdt --- diff --git a/gopt/gopt.icl b/gopt/gopt.icl index 6db4936..1713a6b 100644 --- a/gopt/gopt.icl +++ b/gopt/gopt.icl @@ -35,7 +35,7 @@ combine` sel app p s t = p s (sel t) >>= \(l, as)->pure ((app (const l) t), as) ar0 s f as = Ok o flip tuple as o f -generic gopt a :: Opt a +generic gopt a *! :: Opt a gopt{|Bool|} = BinaryFlag (const True) (const False) gopt{|Int|} = Positionals [\s _->if (and [isDigit c\\c<-:s]) (Ok $ toInt s) (Error ["Not an integer"])] gopt{|Char|} = Positionals [\s _->if (size s == 1) (Ok s.[0]) (Error ["Not a single character"])] @@ -118,7 +118,7 @@ parseOpts _ args a = Ok (a, args) :: T2 = {f :: Int} :: C = A Int | B | C //:: T2 = T Int Int -derive bimap Opt, [], (,), MaybeError +derive binumap Opt, [], (,), MaybeError derive gopt T, T2, C Start w diff --git a/type-restrictions/test.icl b/type-restrictions/test.icl new file mode 100644 index 0000000..5ab2080 --- /dev/null +++ b/type-restrictions/test.icl @@ -0,0 +1,8 @@ +module test + +import StdEnv + +:: T a = T a & toString a + +Start :: T (T Int) +Start = T (T 42)