The need arose when I was writing a full stack web application with PureScript being the frontend and Haskell being the backend. While these two languages are largely similar, the fact that they are different implies that one cannot share the codes directly between them. For all data types defined in Haskell, I have to rewrite them in PureScript. This seemes to be an automatable process so I decided to find a way to let the computer do the work for me! Let’s start with my preferred way of structuring data types in both languages.
PureScript Dealing with data types…
In Functional Programming , we have three terminologies , term , type and kind. Understanding their definitions are crucial to understand functional programming as a practioner.
Terms are runtime values , some examples are 1
, True
and "Hello"
.
Type is the type of a term, the type of 1
is Int
, the type of True
is Boolean
, the type of "Hello"
is String
and so on.
Kind is the type of type. For example, the kind of type Int
is Type
.
Term has type while type has kind.
Let’s start with the simplest data type which is…
FP Enthuasist. Live in Singapore. Works as DevOps Engineer