Skip to content

Commit

Permalink
Handle higher-rank fields in CShow
Browse files Browse the repository at this point in the history
  • Loading branch information
krame505 committed Feb 14, 2024
1 parent 0721ca2 commit d21b756
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Libraries/Base1/CShow.bs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ instance (CShow a) => CShow' (Conc a) where
cshow' (Conc x) = cshow x
cshowP' (Conc x) = cshowP x

instance CShow' (ConcPoly a) where
cshow' (ConcPoly _) = $format "<polymorphic value>"

-- Note that below there are more specific instances for
-- CShow' (Meta (MetaConsNamed ...)) and CShow' (Meta (MetaConsAnon ...))
instance (CShow' a) => CShow' (Meta m a) where
Expand Down
5 changes: 5 additions & 0 deletions testsuite/bsc.lib/CShow/TestCShow.bs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ struct Bar =
data Baz a = Baz a a
deriving (FShow)

struct Qux =
x :: a -> a -- Higher rank
y :: Int 8

sysTestCShow :: Module Empty
sysTestCShow = module
rules
Expand All @@ -35,4 +39,5 @@ sysTestCShow = module
$display (cshow ((vec (Bar {x=42; foo=C}) (Bar {x=3; foo=B 2323})) :: Vector 2 Bar))
$display (cshow ((Bar {x=42; foo=C}) :> (Bar {x=3; foo=B 2323}) :> ListN.nil))
$display (cshow ("x", ((Left 123) :: Either (UInt 8) Bar, False)))
$display (cshow $ Qux {x = id; y = 42;})
$finish
1 change: 1 addition & 0 deletions testsuite/bsc.lib/CShow/sysTestCShow.out.expected
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Baz C (A 12 True (Bar {foo=D {a=0x22; b=C}; x= 42}))
[Bar {foo=C; x= 42}, Bar {foo=B 2323; x= 3}]
[Bar {foo=C; x= 42}, Bar {foo=B 2323; x= 3}]
("x", Left 123, False)
Qux {x=<polymorphic value>; y= 42}

0 comments on commit d21b756

Please sign in to comment.