This article doesn't discuss about something practical but about something experimental.
import Prelude hiding ((.)) send :: Object -> Method -> Object send (Fixnum value) (Method "to_s") = Str $ show value send _ _ = undefined (.) = send data Object = Fixnum Int | Str String deriving Show data Method = Method String deriving Show main = print $ x.to_s where x = Fixnum 10 to_s = Method "to_s"
See the line in main function definition:
print $ x.to_s. This looks like Ruby.
- You can hide the definition of Haskell Prelude "." and can define your own function which name is "."; here I defined
sendfirst then made an alias of it.
- Object and sending method into an object are like just a data and a function which receives an argument of a specific type unless you think about class or prototype; or just, say, "performance."