Canonical modules of partially ordered sets