Skip to content

sgrauel/immutablelist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

A first implementation of an immutable list in Scala

This list uses a the type constructor pattern with subtype polymorphism between the type constructor and data constructors along with a companion object to facilitate the implementation of an immutable linked list. The fundemental methods like cons, concat, head and tail are contained in the data instances generated by the data constructors, but other critical method components are organized within the companion object e.g. 'map', 'filter'. The design shows that particular elegance associated with the combination of functional and imperative polymorphisms to attain greater code modularity and power of generalization. In addition to the methods, the object also serves to organize a type class component that defines and describes the general behavior of what is means to combine two types into one i.e. a combiner typeclass or 'monoid' typelcass and one or more associated 'type instances' i.e. type members of the typeclass that implement and support the general behavior that the typeclass defines and describes. This is so called 'ad hoc' polymorphism, a polymorphism that takes place to the side in contrast to subtype polymorphism which is more hiarchically based. Ultimately though the goal of the typeclass and its ad-hoc polymorphism is to add one or more behaviors to any given type added to its domain while hiarchical subtype/supertype relations can be constructed among them to create a chain of dependencies of types to stack the behaviors for that type in question. This makes typeclasses and ad-hoc polymorphism a particularly intriguing area of study when it comes to code integration.

About

an immutable list in Scala

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages