I found ranges on ints what about enforcing even or odd?
-
-
Let's take Even as an example. Step one: define it as a newtype of int.
1 reply 0 retweets 0 likes -
Replying to @JulianBirch @otfrom and
2) Add methods that respect the Even-ness. 3) Expose a single factory method int -> Maybe Even
1 reply 0 retweets 0 likes -
Replying to @JulianBirch @otfrom and
This gets you pretty good guarantees that things are Even within Even world and has a runtime gatekeeper
2 replies 0 retweets 0 likes -
Replying to @JulianBirch @otfrom and
Ofc, spec looks more like refinement types, for which there's a project called Liquid Haskell.
1 reply 0 retweets 0 likes -
Replying to @JulianBirch @otfrom and
But I can't really explain that, because I don't understand it.
2 replies 0 retweets 0 likes -
I suppose that is one nice thing about spec. I don't find it difficult to understand.
1 reply 0 retweets 1 like -
definitely. PL is a tool for thought and clj helps me think better than anything else I've found
1 reply 0 retweets 0 likes -
Haskell's pretty good for this too, but there's _much_ more to learn and it rewards investment.
1 reply 0 retweets 0 likes -
Agree. I wonder if I haven't put in enough time or is clj simply a better match for how I approach problems.
1 reply 0 retweets 0 likes
and then there is of course the "tools works on both ends" thing.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.