module TypeOp (x, type (~)(), type ($%), default (:%), default ($%)) whereimport Data.Coerce-- import and export types (with class syntax)import Primitives (type (~)(..))data a + b = Plus a btype Foo = Int + Boolx :: Int `Either` Boolx = Left 5type a ~~ b = Coercible a bclass a ~~ b => TypeOp a binstance a ~~ b => TypeOp a bf :: a ~~ b => a -> bf = coercemain :: IO ()main = print (f x :: Either Int Bool)-- Check that various combinations parse.type (:$$) = Maybetype (:+) a = Maybe atype (a :$) = atype a :++ b = Either a btype (a :+++ b) c = (a,b,c)type ($$$) = Maybetype ($+) a = Maybe atype (a $$) = atype a $++ b = Either a btype (a $+++ b) c = (a,b,c)data (:$%$)data (:$$%) adata (a :$$$%)data a :$%% bdata (a :$%%% b) cclass (:%$) whereclass (:%) a whereclass (a :$%) whereclass a :%% b whereclass (a :%%% b) c whereclass (%$%) whereclass ($%) a whereclass (a $$%) whereclass a $%% b whereclass (a $%%% b) c wherex1 :: ($%) a => ax1 = undefinedx2 :: ($%%) a b => ax2 = undefinedx3 :: a $%% b => ax3 = undefinedx4 :: ($%%%) a b c => ax4 = undefinedx5 :: (a $%%% b) c => ax5 = undefinedx6 :: (a $$%) => ax6 = undefinedinstance ($%) Intinstance (Int $$%)instance Int $%% Intinstance ($%%) Bool Boolinstance (Int $%%% Int) Intdefault (:%) (Int)default ($%) (Int)default ((:$%$))default ($$%) ((:$%$))