network protocol logic with free monads