A common pattern I stumbled upon while implementing small logic checkers is using a list monad to do computations with backtracking then returning true or false depending on whether the list is empty (nonempty list means there is at least one solution). However, this practice doesn't make intention clear in the function type. Today, I converted this small minimal logic checker I wrote a while ago to the following:
if you want to make intent more clear in the types, wouldn't it be best to return the actual solution itself instead of a Bool? as proof that you found it
A common pattern I stumbled upon while implementing small logic checkers is using a list monad to do computations with backtracking then returning true or false depending on whether the list is empty (nonempty list means there is at least one solution). However, this practice doesn't make intention clear in the function type. Today, I converted this small minimal logic checker I wrote a while ago to the following:
Any feedback on this style? Mainly the consecutive
guard $ ...
.if you want to make intent more clear in the types, wouldn't it be best to return the actual solution itself instead of a
Bool
? as proof that you found it