Protocols as types