

Refinement types in Haskell as a library - nikita-volkov
http://nikita-volkov.github.io/refined/

======
mijoharas
Can someone who knows more about haskell than me explain whether:

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!

~~~
dllthomas
Using the Template Haskell bits have all the disadvantages of Template Haskell
- mostly a slower compile. Other than that, I don't see many downsides. As
mentioned in the discussion on r/haskell, things get a little tricky when your
arguments interact, but if you're okay with uncurrying you can still verify
that you've got a sane combination:
[http://www.reddit.com/r/haskell/comments/3425pk/refinement_t...](http://www.reddit.com/r/haskell/comments/3425pk/refinement_types_as_a_library/cqqik1i)

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 :)

------
nemo1618
Nice, but I was hoping for something like:

    
    
      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.)

~~~
ics
Regarding &:
[https://www.fpcomplete.com/hoogle?q=%26&env=ghc-7.8-stable-1...](https://www.fpcomplete.com/hoogle?q=%26&env=ghc-7.8-stable-14.09)

If it's from lens, then it's "the flipped version of ($)".

~~~
CMCDragonkai
What's the difference (&) and reverse function composition?

~~~
dllthomas
Precisely the difference between function application and function
composition.

