freesPat :: Pat BitSet -> BitSet
freesPat p0 =
  case p0 of
    PVar  _ i tp -> tp `shiftR` i
    PUnused i tp -> tp `shiftR` i
    PUnit      -> 0
    PPair x y  -> freesPat x .|. freesPat y
    PRecord pm -> bitwiseOrOf folded (freesPat <$> pm)
    PCtor _ pl -> bitwiseOrOf folded (freesPat <$> pl)
freesPat :: Pat BitSet -> BitSet
freesPat p0 =
  case p0 of
    PVar  _ i tp -> tp `shiftR` i
    PUnused i tp -> tp `shiftR` i
    PUnit      -> 0
    PPair x y  -> freesPat x .|. freesPat y
    PRecord pm -> bitwiseOrOf folded (freesPat <$> pm)
    PCtor _ pl -> bitwiseOrOf folded (freesPat <$> pl)
freesPat p0 =
  case p0 of
    PVar  _ i tp -> tp `shiftR` i
    PUnused i tp -> tp `shiftR` i
    PUnit      -> 0
    PPair x y  -> freesPat x .|. freesPat y
    PRecord pm -> bitwiseOrOf folded (freesPat <$> pm)
    PCtor _ pl -> bitwiseOrOf folded (freesPat <$> pl)