Source. [40b80852408bd2b1]

  dia = hcat
    [ inout 3 "x"
    , rect 9 4 <> text "A" # translate ((-3.5) ^& (-1)) <>
      hcat
      [ inout 3 "f(x)"
      , text "B" <> rect 3 2
      , inout 3 "y"
      ]
      # centerXY
    , inout 3 "g(y)"
    ]
    where
      inout l t = mconcat
        [ centerX (text t) # translateY 0.8 # fontSizeL 0.8
        , arrowV' (with & headLength .~ local 0.3) (l *^ unitX) # centerX
        ]