In many articles about Haskell they say it allows to make some checks during compile time instead of run time. So, I want to implement the simplest check possible - allow a
I know that this was answered a long time ago and I already provided an answer of my own, but I wanted to draw attention to a new solution that became available in the interim: Liquid Haskell, which you can read an introduction to here.
In this case, you can specify that a given value must be positive by writing:
{-@ myValue :: {v: Int | v > 0} #-}
myValue = 5
Similarly, you can specify that a function f
requires only positive arguments like this:
{-@ f :: {v: Int | v > 0 } -> Int @-}
Liquid Haskell will verify at compile-time that the given constraints are satisfied.