Marc Knaup
12/30/2019, 8:35 AMUnit
.
How should I denote that a parameter takes no value? Unit
or Nothing?
?
That’s relevant in a generic context like Visitor<Result, Data>
where some visitors need no input and hence use Unit
or Nothing?
as Data
.Scott Christopher
12/31/2019, 6:41 AMUnit
type has one single possible instance (Unit
), while Nothing
has no value instances. With that in mind, Unit -> A
is a function that doesn't require anything interesting to produce an A
, while Nothing -> A
is a function that can never be called because it's not possible to create the argument instance to call it with.Marc Knaup
12/31/2019, 7:37 AMUnit
and Nothing?
, i.e. an optional Nothing
.
Both have exactly one value: Unit
has Unit
and Nothing?
has null
.Scott Christopher
12/31/2019, 8:21 AMMarc Knaup
12/31/2019, 8:25 AMNothing?
in that case so I think it’s a topic worth discussing 😄Scott Christopher
12/31/2019, 8:29 AMMarc Knaup
12/31/2019, 8:30 AMUnit
means there’s a value (Unit
) and null
better represents the absence of a value.Scott Christopher
12/31/2019, 8:32 AMMarc Knaup
12/31/2019, 8:32 AM