godpt
[clean-tests.git] / gopt / gopt.icl
index 57cf229..09089ab 100644 (file)
@@ -36,12 +36,13 @@ 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 [("INT", \s _->if (and [isDigit c\\c<-:s]) (Ok $ toInt s) (Error ["Not an integer"]))]
 gopt{|Char|} = Positionals [("CHAR", \s _->if (size s == 1) (Ok s.[0]) (Error ["Not a single character"]))]
 gopt{|String|} = Positionals [("STRING", \s _->Ok s)]
-gopt{|RECORD|} f = bifmap (\(RECORD a)->a) RECORD f
-gopt{|OBJECT|} f = bifmap (\(OBJECT a)->a) OBJECT f
+gopt{|RECORD|} f = bifmap (\(RECORD a)->a) (\x->RECORD x) f
+gopt{|OBJECT|} f = bifmap (\(OBJECT a)->a) (\x->OBJECT x) f
 gopt{|FIELD of {gfd_name}|} f = case f of
        //Child is a boolean
        BinaryFlag set unset = mapF $ Flags [(gfd_name, ar0 gfd_name set), ("no-" +++ gfd_name, ar0 ("no-" +++ gfd_name) unset)]
@@ -54,7 +55,7 @@ gopt{|FIELD of {gfd_name}|} f = case f of
        x = abort "Subparsers not supported"
 where
        mapF :: ((m a) -> m (FIELD a)) | bifmap m
-       mapF = bifmap (\(FIELD a)->a) FIELD
+       mapF = bifmap (\(FIELD a)->a) (\x->FIELD x)
 
        ptoarg [p] [] i = Error ["Not enough arguments for " +++ gfd_name]
        ptoarg [(_, p):ps] [a:as] i = p a i >>= ptoarg ps as