11 comments

[ 2.4 ms ] story [ 37.1 ms ] thread
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.)

Dependently typed languages like DML, Epigram, ATS, Coq, Agda or Idris supports these kind of types. Unfortunately it quickly becomes difficult to work with this kind of typing when you introduce more complex properties.
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!

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

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