3 ms·
I don't use haskell very much, but I'm curious what the use is of defining type Symbol = String Why not just have -> String -> in the function's type? The
by hyperhopper 10y ago
I don't use haskell very much, but I'm curious what the use is of defining
type Symbol = String
Why not just have -> String -> in the function's type? The only thing I see this gains is forcing you to add extra boilerplate everywhere converting strings to "Symbol"s
- chrissoundz 10y agoIt is just a type alias as far as I know. I suppose it adds more 'annotation' to your program, in addition if you decide to change the type of Symbol to be an Int or String String then you have a single reference to change initially.
- the_af 10y ago"type" simply defines a synonym. You use it similarly to how you'd use a typedef in C. You don't need to convert anything, it just gives a more meaningful name to an existing type.