let inline (|HasLength|) x = 
  fun () -> (^a: (member Length: int) x)

// `this` is optional here, just for demonstration of `as` pattern
let inline length (HasLength f as this) = f()

// It works!
let foo = length [1; 2; 3]
let bar = length [|1; 2; 3|]