News for hackers. Stuff that matters.
Re:Dimensions and Haskell: Singletons in Action by shoo on Friday July 19, 2019 @05:58PM (#20482795)
"singletons" in this context is apparently some mechanism applied here to type-check matrix dimensions... :

> we put dimensions of data types on the type level to avoid a large set of errors that might arise at the runtime stage. During the compile stage, one may check some properties of matrix dimensions expressed via type-level natural numbers and find out the reason of that error as a type error.

> In this part, we describe our approach to the matrix data type that is parameterised via its numbers of columns and rows

> In this approach, matrix dimensions are lifted to the type level with the use of the Singletons library. At first glance, our solution looks a bit sophisticated. Why? There remains a question about the way to make it less devious and more idiomatic. In other words, we have to recognise the restrictions of Haskell expressive opportunities. What about performance? Also, our approach helps to remove only errors that affect the dimensions of arrays. Can we track other array parameters to reduce a set of possible runtime errors even more?

... not the horrible "singleton" design pattern https://en.wikipedia.org/wiki/Singleton_pattern

Prior art for identifying errors due to mismatched array dimensions include:

* (Eigen, C++) support for compile-time static assertions in some situations: https://eigen.tuxfamily.org/dox/TopicAssertions.html

* (numpy, python) raising ValueErrors at runtime about shape misalignment

Re:Dimensions and Haskell: Singletons in Action by NaeosPsy on Friday July 19, 2019 @06:04PM (#20482834)
http://hackage.haskell.org/package/singletons

Singletons is a Haskell library. In this context, it is used to emulate dependent types which Haskell does not yet have.

Re:Dimensions and Haskell: Singletons in Action by thesz on Saturday July 20, 2019 @05:42AM (#20484872)
I have to say that Eigen would have hard time being prior art: http://okmij.org/ftp/Haskell/number-parameterized-types.html

It's from 2007 and I think it is older than Eigen.