-- SimValue 0 []

    -- chan :: Monad m => Int -> value -> MkPNMonad m value Chan
    chan :: Width -> Int -> MkPNMonad SimFlow SimValue Chan
    chan width depth = do
        inp <- pair
        out <- if depth == 0
            then return inp
            else foldM makeLatch inp [1..depth]
        return (out, inp)
        where
            makeLatch inp i = withLabel (show i) $ do
                out <- pair
                latch inp out
                return out

            pair = do
                req <- withLabel "r" $ newNumericPlace width []
                ack <- withLabel "a" $ newBlackPlace []
                return (req, ack)
chan :: Width -> Int -> MkPNMonad SimFlow SimValue Chan
chan width depth = do
        inp <- pair
        out <- if depth == 0
            then return inp
            else foldM makeLatch inp [1..depth]
        return (out, inp)
        where
            makeLatch inp i = withLabel (show i) $ do
                out <- pair
                latch inp out
                return out

            pair = do
                req <- withLabel "r" $ newNumericPlace width []
                ack <- withLabel "a" $ newBlackPlace []
                return (req, ack)
chan width depth = do
        inp <- pair
        out <- if depth == 0
            then return inp
            else foldM makeLatch inp [1..depth]
        return (out, inp)
        where
            makeLatch inp i = withLabel (show i) $ do
                out <- pair
                latch inp out
                return out

            pair = do
                req <- withLabel "r" $ newNumericPlace width []
                ack <- withLabel "a" $ newBlackPlace []
                return (req, ack)