handleFileSelect is an Impure Function
#handleFileSelect is an Impure Function
handleFileSelect has in your code snippet a dependence to fr which is decleraded outside of the function. To make the function pure you can pass fr as argument.
#Put Side Effects Into a Wrapper
Put Side Effects Into a Wrapper
Either You Can Parse to a JSON or Not..
#Either You Can Parse to a JSON or Not..
InIn the following I want to introduce a functor calles Either which is split into to functors Left and Right. If we can parse a string succesfully we will return a Right with the parsed value otherwise we will return Left with an error message.