Skip to content

Commit 9381a58

Browse files
committed
Add util to unwrap a Port value
1 parent f6bdfb0 commit 9381a58

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Libraries/Base1/Prelude.bs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ package Prelude(
260260

261261
primMethod, -- TODO: Needed only in PreludeBSV for vMkRWire1, should be removed.
262262
WrapField(..), WrapMethod(..), WrapPorts(..),
263-
Port(..), SplitPorts(..)
263+
Port(..), unPort, SplitPorts(..)
264264
) where
265265

266266
infixr 0 $
@@ -4629,6 +4629,9 @@ class SplitPorts a p | a -> p where
46294629
data Port a = Port a
46304630
deriving (FShow)
46314631

4632+
unPort :: Port a -> a
4633+
unPort (Port a) = a
4634+
46324635
-- XXX if the default instance is the only one, then it gets inlined in CtxReduce
46334636
-- and other instances for this class are ignored.
46344637
instance SplitPorts () () where
@@ -4639,7 +4642,7 @@ instance SplitPorts () () where
46394642
-- Default instance: don't split anything we don't know how to split.
46404643
instance SplitPorts a (Port a) where
46414644
splitPorts = Port
4642-
unsplitPorts (Port a) = a
4645+
unsplitPorts = unPort
46434646
portNames _ base = Cons base Nil
46444647

46454648
{-

src/Libraries/Base1/SplitPorts.bs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ class DeepSplitPorts a p | a -> p where
9292

9393
instance DeepSplitPorts (UInt n) (Port (UInt n)) where
9494
deepSplitPorts = Port
95-
deepUnsplitPorts (Port x) = x
95+
deepUnsplitPorts = unPort
9696
deepSplitPortNames _ base = Cons base Nil
9797

9898
instance DeepSplitPorts (Int n) (Port (Int n)) where
9999
deepSplitPorts = Port
100-
deepUnsplitPorts (Port x) = x
100+
deepUnsplitPorts = unPort
101101
deepSplitPortNames _ base = Cons base Nil
102102

103103
instance DeepSplitPorts () () where

0 commit comments

Comments
 (0)