Hello guys. It is advisable to avoid partial functions in Haskell code, as said by Haskell wiki. For example, mod
is partial and should be avoided. But I’ve got a question here. A function f
which calculates a number modulo 7 can be defined such that f x = x mod 7
. Is this partial? My opinion is that it can evaluate a value for each x so it is not although is uses a partial function. And is this a good practice which does not violate the practice that partial functions are avoided? If not, what am I supposed to write in this scenario?
2 Likes
yeah it’s alright to use such a function because you pass it a constant, so in a sense you “prove” that it can’t be 0 (if your constant is 7)
4 Likes