Refinement types in Haskell as a library
nikita-volkov.github.io
nikita-volkov.github.io
1. there are any disadvantages to using this library
2. there are any comparable libraries that I should/could be using instead (obviously with reasons as to why it's better/worse).
because this sounds great and I now want to start using it everywhere!
It also may require some explicit conversions in places they shouldn't strictly be necessary.
Other than that, I don't see any downsides. There do seem to be a couple similar libraries, but feel free to start using it everywhere :)
slice :: Int{1..} -> [a] -> [[a]]
slice n l =
splitAt n l & \(a, b) -> a : slice n b
I don't think this is possible in Haskell. Is there a language that supports this sort of syntax?(Also, what's up with that &? It doesn't seem to be a Prelude operator.)
If it's from lens, then it's "the flipped version of ($)".
An example from that paper:
type Nat = {v:Int | 0 <=v }
type Pos = {v:Int | 0 < v }
div :: Nat -> d:Pos -> {v:Nat | v <= n}
The ATS programming language (http://www.ats-lang.org) is more ML-like than Haskell-like but can have ranged integer types. Something like: fun slice {n:int | n >= 1} (a:int n, b:list)It's now in [Data.Function of "base"](http://hackage.haskell.org/package/base-4.8.0.0/docs/Data-Fu...) and hence in ["base-prelude"](http://hackage.haskell.org/package/base-prelude).