Earlier quoted context omitted.
Label the string as a functor and think about lifting the array into the string functor and doing string manipulation to change it to a dict, then lift it back into a dict type. String manipulations of a lifted type in "string space" can be faster and more efficient then actually manipulating it in "type space"
What?
The OP said that there's no point in labeling an arbitrary type as a functor or monadic value. I'm going to use an example to illustrate how there is a benefit in being aware of this concept. I will be using a "String Monad" in my example.
Imagine you have some type, like in the initial example.
And you want to convert that type into another type.
I'll give you an arbitrary example using python:
You want to convert this: {1:2 ,3:4, 5:6, 7:8}
To this: [1,2,3,4,5,6,7,8]
You can do this via loops or you can "lift" the dictionary type from "type space" to "string space" via the python functor str():
lifted_dictionary = str({1:2 ,3:4, 5:6, 7:8})
This is similar to movement between two categories or objects via a functor. You see similar techniques in other fields of engineering when say someone "lifts" something from cartesian coordinates to polar coordinates. Which is why I'm using the word "space" it's similar to how I'm shifting representations of coordinates to have an easier time with certain calculations.Then you do your type manipulations in "string space" rather then on the type itself. So it all ends up being string manipulation operations to get from the string "{1:2 ,3:4, 5:6, 7:8}" to the string "[1,2,3,4,5,6,7,8]". I didn't use regexp in the example below but you get a huge performance boost if you use that instead.
lifted_array = "{1:2 ,3:4, 5:6, 7:8}".replace('{','[').replace('}',']').replace(':',', ')
#computed value is a string of the form: "[1,2,3,4,5,6,7,8]"
Then you use the opposite functor from str() to lift the value back into "type space" array = eval(lifted_array)
Here eval() is the opposite functor to str()Type conversion complete. The full code:
original_dict = {1:2 ,3:4, 5:6, 7:8}
array = eval(str(original_dict).replace('{','[').replace('}',']').replace(':',', '))
#value of array is [1,2,3,4,5,6,7,8]
Essentially you use functors to lift your data structures into other categories for easier conversion, then you simply bring the stringified type back down into regular "type space".So in short I took types and lifted it into the String Monad or "String Category" or whatever you want to call it, then brought back down into types.
It seems like an arbitrary way to do type conversion but using regexp to do string manipulation in place of a for loop that unrolls the dictionary is more performant and faster. Think about preserving order as well. When I convert the dict type into string space, ordinal properties of the string itself will be enforced on the dict. SO the keys in the dict will follow the order they appear in the string as will the array string that it is converted to.
This technique utilizes category theory. The categories you are lifting to must be isomorphic to the origin category, you must understand the notion of functors (or monadic values) to really get it.