-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
When generating a function such as Option[A] => Option[A]
, the preferred implementation would be x => x
. Sometimes code such as this is generated:
Warning:(141, 89) type (A ⇒ Option[B]{None.type + Some[B]}) ⇒ (B ⇒ Option[C]{None.type + Some[C]}) ⇒ A ⇒ Option[C]{None.type + Some[C]} has 2 implementations (laws need checking?):
a ⇒ b ⇒ c ⇒ a c match { d ⇒ (None() + 0); e ⇒ b e.value } [score: (0,0.5,0.0,0,0)];
a ⇒ b ⇒ c ⇒ (None() + 0) [score: (3,0.0,0.0,0,0)].
def kleisliOptCompose[A, B, C](f: A ⇒ Option[B], g: B ⇒ Option[C]): A ⇒ Option[C] = implement
It is better to generate code such as x match { d => d }; ...
instead of x match { d => None() + 0 }; ...
when d
is itself already None()
. This code would have a lower information loss score.
Metadata
Metadata
Assignees
Labels
No labels