makeComp :: NetworkIF network => [Part network] -> Part network -> DM.Map NetworkLinkRef Chan ->
        NetworkComp -> MkPNMonad SimFlow SimValue ()
    makeComp _ part chans (TeakComp compNo teakTyp links _) = do
        let
            chanLinks = map (fmap (chans DM.!)) links
            linkWidths = tryPart part $ mapM' (mapM' nwGetLinkWidth . flattenSome) links
            partName = networkName part

        withLabel partName $ withLabel ("C" ++ show compNo) $ do
            case (teakTyp, chanLinks, linkWidths) of
                (TeakR, [One out], _) -> teakR out
                (TeakI, [One inp, One out], _) -> teakI inp out
                (TeakM, [Many inp, One out], [_, [width]]) -> teakM width inp out
                (TeakS guardSlice impsXOffsets, [One inp, Many out], [[inpWidth], outWidths]) -> let
                    (impss, offsets) = unzip impsXOffsets
                    outSlices = zipWith (+:) offsets outWidths
                    in teakS inpWidth guardSlice outSlices impss inp out
                (TeakF offsets, [One inp, Many out], [_, outWidths]) ->
                    teakF (zipWith (+:) offsets outWidths) inp out
                (TeakJ, [Many inp, One out], [inpWidths, _]) -> teakJ inpWidths inp out
                (TeakA, [Many inp, One out], [_, [width]]) -> teakA width inp out
                (TeakO terms, [One inp, One out], _) -> teakO terms inp out
                (TeakV _ width _ wOffsets rOffsets, [Many wg, Many wd, Many rg, Many rd],
                    [wWidths, _, _, rWidths]) -> teakV width
                        (zipWith (+:) wOffsets wWidths)
                        (zipWith (+:) rOffsets rWidths) wg wd rg rd
                (_, _, _) -> error $ "makeComp: unrecognised component " ++ show teakTyp
makeComp :: NetworkIF network => [Part network] -> Part network -> DM.Map NetworkLinkRef Chan ->
        NetworkComp -> MkPNMonad SimFlow SimValue ()
makeComp _ part chans (TeakComp compNo teakTyp links _) = do
        let
            chanLinks = map (fmap (chans DM.!)) links
            linkWidths = tryPart part $ mapM' (mapM' nwGetLinkWidth . flattenSome) links
            partName = networkName part

        withLabel partName $ withLabel ("C" ++ show compNo) $ do
            case (teakTyp, chanLinks, linkWidths) of
                (TeakR, [One out], _) -> teakR out
                (TeakI, [One inp, One out], _) -> teakI inp out
                (TeakM, [Many inp, One out], [_, [width]]) -> teakM width inp out
                (TeakS guardSlice impsXOffsets, [One inp, Many out], [[inpWidth], outWidths]) -> let
                    (impss, offsets) = unzip impsXOffsets
                    outSlices = zipWith (+:) offsets outWidths
                    in teakS inpWidth guardSlice outSlices impss inp out
                (TeakF offsets, [One inp, Many out], [_, outWidths]) ->
                    teakF (zipWith (+:) offsets outWidths) inp out
                (TeakJ, [Many inp, One out], [inpWidths, _]) -> teakJ inpWidths inp out
                (TeakA, [Many inp, One out], [_, [width]]) -> teakA width inp out
                (TeakO terms, [One inp, One out], _) -> teakO terms inp out
                (TeakV _ width _ wOffsets rOffsets, [Many wg, Many wd, Many rg, Many rd],
                    [wWidths, _, _, rWidths]) -> teakV width
                        (zipWith (+:) wOffsets wWidths)
                        (zipWith (+:) rOffsets rWidths) wg wd rg rd
                (_, _, _) -> error $ "makeComp: unrecognised component " ++ show teakTyp
makeComp _ part chans (TeakComp compNo teakTyp links _) = do
        let
            chanLinks = map (fmap (chans DM.!)) links
            linkWidths = tryPart part $ mapM' (mapM' nwGetLinkWidth . flattenSome) links
            partName = networkName part

        withLabel partName $ withLabel ("C" ++ show compNo) $ do
            case (teakTyp, chanLinks, linkWidths) of
                (TeakR, [One out], _) -> teakR out
                (TeakI, [One inp, One out], _) -> teakI inp out
                (TeakM, [Many inp, One out], [_, [width]]) -> teakM width inp out
                (TeakS guardSlice impsXOffsets, [One inp, Many out], [[inpWidth], outWidths]) -> let
                    (impss, offsets) = unzip impsXOffsets
                    outSlices = zipWith (+:) offsets outWidths
                    in teakS inpWidth guardSlice outSlices impss inp out
                (TeakF offsets, [One inp, Many out], [_, outWidths]) ->
                    teakF (zipWith (+:) offsets outWidths) inp out
                (TeakJ, [Many inp, One out], [inpWidths, _]) -> teakJ inpWidths inp out
                (TeakA, [Many inp, One out], [_, [width]]) -> teakA width inp out
                (TeakO terms, [One inp, One out], _) -> teakO terms inp out
                (TeakV _ width _ wOffsets rOffsets, [Many wg, Many wd, Many rg, Many rd],
                    [wWidths, _, _, rWidths]) -> teakV width
                        (zipWith (+:) wOffsets wWidths)
                        (zipWith (+:) rOffsets rWidths) wg wd rg rd
                (_, _, _) -> error $ "makeComp: unrecognised component " ++ show teakTyp