Hacker News new | past | comments | ask | show | jobs | submit login

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



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


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




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: