Re:Functional calisthenics
by derefr on Thursday October 19, 2017 @04:41PM
(#15511370)
You know, you're talking about a very specific kind of OOP here. Elixir, for example, is a language I'd call OOP—but it doesn't have classes. It just has "bare functions" in modules, where a module's functions will usually expect values of the type the module is named after.
Also, to reverse that perspective, a "type" in Erlang/Elixir-lang is just any data formatted in a way that a given set of functions will work with it, rather than requiring an explicit tag. {1, 2} can be an instance of a type†, if you have a module Foo that spits that shape of data in response to Foo.new/0 and takes it for Foo.change/1.
Also, to reverse that perspective, a "type" in Erlang/Elixir-lang is just any data formatted in a way that a given set of functions will work with it, rather than requiring an explicit tag. {1, 2} can be an instance of a type†, if you have a module Foo that spits that shape of data in response to Foo.new/0 and takes it for Foo.change/1.
† An example of such a type is Erlang's http://erlang.org/doc/man/queue.html . queue:new/0 just returns {[], []}.