import Diagrams.Prelude
import Control.Monad
import Data.Bits (xor)
k = round $ logBase 2 16
n = 2^k
diagram $ mconcat [ fromVertices [p2 (0,y₀), p2 (n,y₁)]
| [y₀,y₁] <- replicateM 2 [0..n-1] ]
diagram $ hsep 0 [ mconcat [
fromVertices [p2 (0,fromIntegral y₀), p2 (4, fromIntegral y₁)]
| y₀ <- [0..n-1], y₁ <- [y₀, y₀`xor`2^o] ] | o <- [0..k-1] ]