diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 105750bbb3..1cf3a9eb01 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -59,7 +59,7 @@ M: word pprint* M: method pprint* ; @@ -206,6 +206,8 @@ M: tuple pprint-delims drop \ T{ \ } ; M: wrapper pprint-delims drop \ W{ \ } ; M: callstack pprint-delims drop \ CS{ \ } ; M: hash-set pprint-delims drop \ HS{ \ } ; +M: anonymous-union pprint-delims drop \ union{ \ } ; +M: anonymous-intersection pprint-delims drop \ intersection{ \ } ; M: object >pprint-sequence ; M: vector >pprint-sequence ; @@ -215,6 +217,8 @@ M: hashtable >pprint-sequence >alist ; M: wrapper >pprint-sequence wrapped>> 1array ; M: callstack >pprint-sequence callstack>array ; M: hash-set >pprint-sequence members ; +M: anonymous-union >pprint-sequence members>> ; +M: anonymous-intersection >pprint-sequence participants>> ; : class-slot-sequence ( class slots -- sequence ) [ 1array ] [ [ f 2array ] dip append ] if-empty ; @@ -253,6 +257,8 @@ M: hashtable pprint* M: curry pprint* pprint-object ; M: compose pprint* pprint-object ; M: hash-set pprint* pprint-object ; +M: anonymous-union pprint* pprint-object ; +M: anonymous-intersection pprint* pprint-object ; M: wrapper pprint* { @@ -262,10 +268,4 @@ M: wrapper pprint* } cond ; M: maybe pprint* - > pprint-word block> ; - -M: anonymous-union pprint* - > [ pprint-word ] each \ } pprint-word block> ; - -M: anonymous-intersection pprint* - > [ pprint-word ] each \ } pprint-word block> ; + > pprint-class block> ; diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 3df231db96..b3d78268d2 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -1,11 +1,11 @@ USING: accessors arrays classes.intersection classes.maybe classes.union compiler.units continuations definitions effects -eval generic generic.standard io io.streams.duplex +eval generic generic.standard hashtables io io.streams.duplex io.streams.string kernel listener make math namespaces parser prettyprint prettyprint.config prettyprint.private prettyprint.sections see sequences splitting -tools.continuations tools.continuations.private tools.test -vectors vocabs.parser words ; +strings tools.continuations tools.continuations.private +tools.test vectors vocabs.parser words ; IN: prettyprint.tests [ "4" ] [ 4 unparse ] unit-test @@ -427,3 +427,25 @@ TUPLE: fo { a intersection{ fixnum integer } initial: 0 } ; ] [ [ \ fo see ] with-string-writer ] unit-test + +[ +"""union{ + union{ float integer } + intersection{ string hashtable } +} +""" +] [ [ union{ union{ float integer } intersection{ string hashtable } } . ] with-string-writer ] unit-test + +[ +"""intersection{ + union{ float integer } + intersection{ string hashtable } +} +""" +] [ [ intersection{ union{ float integer } intersection{ string hashtable } } . ] with-string-writer ] unit-test + +[ +"""maybe: union{ float integer }\n""" +] [ + [ maybe: union{ float integer } . ] with-string-writer +] unit-test diff --git a/core/classes/maybe/maybe.factor b/core/classes/maybe/maybe.factor index 37adf2331d..f0b05f88ee 100644 --- a/core/classes/maybe/maybe.factor +++ b/core/classes/maybe/maybe.factor @@ -5,7 +5,7 @@ classes.algebra.private classes.private classes.union.private effects kernel words ; IN: classes.maybe -TUPLE: maybe { class word initial: object read-only } ; +TUPLE: maybe { class classoid initial: object read-only } ; C: maybe