3 ms·
yep, I wrote this : https://github.com/Mparaiso/lodash-go https://github.com/Mparaiso/lodash-go which is in theory "runtime type safe" in the sense that is yi
by interactiv 10y ago
yep, I wrote this :
https://github.com/Mparaiso/lodash-go https://github.com/Mparaiso/lodash-go
which is in theory "runtime type safe" in the sense that is yields an error if types do not match , but it uses reflection which leads to a huge performance hit.
The irony is that Go is a perfectly capable functional language when one opts out of Go type system. (Don't use that package, this is not idiomatic Go).
- burntsushi 10y agoSee also: http://blog.burntsushi.net/type-parametric-functions-golang/ http://blog.burntsushi.net/type-parametric-functions-golang/
- interactiv 10y agoYes, if you look at the source code I use unification to tell whether types match or not.
- burntsushi 10y agoYou're doing a lot of repeated work though. I was trying to point out this function, which does unification in a generic context, given some function type: https://godoc.org/github.com/BurntSushi/ty#Check https://godoc.org/github.com/BurntSushi/ty#Check ... For example, it reduces a lot of the reflection boiler plate: https://github.com/BurntSushi/ty/blob/master/fun/list.go#L80 https://github.com/BurntSushi/ty/blob/master/fun/list.go#L80