I’ve long been annoyed that value types don’t have strong semantic information attached to them such that the compiler would barf if I try and pass an value type that isn’t semantically the same as what the function wanted. For example, what does the following signature mean other than than taking in 2 ints and returning a bool?
IsLoggedIn :: int -> int -> bool
What I’d really like the signature to look like is
IsLoggedIn :: UserId -> SessionId -> bool
In F# you can do this sort of with type aliases and augmenting the signature with the type information. However, its just editor magic, it doesn’t actually compile to anything that would stop you from accidentally calling a function with the arguments reversed. An int is an int is an int, right?
var userId = 1 var sessionId = 2 IsLoggedIn(sessionId, userId)
This is perfectly valid to the … Read more