I failed to publish OrgNoteApp. I created many small modules in the development process. I call them items in my engineering toolbox. Recently, one of the modules (diffing) is shipped to millions of customers. It’s part success and part learning. Enter FastDiff and its little story.Read More
Equality on Error
Functor >> Applicative >> Monad
Functional programming is out there. Partly rumor, partly practiced, partly understood. I have been writing about them for around 6 months. In this post, I want to summarize the main terminologies (jargons) very concisely, with example and best of all, with swift code. For a full explanation, I will link to my previous blogs and external resources as we go along. Lets get going.Read More
Don't Fear Custom Operator!
Table of Contents Introduction Creating custom operator Operator overload (The bad) Operator overload (The good) Custom Operator Normal composition Direct composition Left to Right application operator Creating Custom Operator |> 3 Q’s before introducing custom operator Custom operator for map fmap or map |» operator Conclusion Introduction Operator (+, -, >) are just normal functions. Treated a bit differently (syntatically) by the compiler.Read More
Extensible Analytics Library Design with Tagless final concept
Table of Contents Keywords Expression Problem Introduction Following the ritual Not following the ritual Preface 2 classical ways to implement analytics library Enum based (Sum type based) Class, struct+protocol based (product type based) Client problem: Add ForceTapEvent & support another analytics service The limitation of enum approach The limitation of class/(struct+protocol) based approach Summarizing A radical way to solve the same issue aka Tagless final Lets get both: ability to add cases and new interpretation.Read More
Testable Interface design with Enums
Table of Contents Writing Testable Swift API with Enums Modeling interface based on Enum Using the OneTapFeature Testing Feature Refactoring the OneTapFearure to make it testable How about testing the present() What if our client module is using Obj-C Is the feature modular? Can it be resused by other apps? Conclusion Writing Testable Swift API with Enums Encapsulate everything and try to show as little as possible. Greedy approach.Read More
Monadic Networking: I Promise!
This post abstracts handling async tasks and come up with declarative linearized API model. Async tasks includes nested networking, nested animation and even nested multi-threading compute intensive code blocks. Async task is one of side effect programming technique. Side effect is integral part of programming; mutating state, printing to screen/paper, asynctask to download JSON, keeping a running counter, locking/unlocking thread are all examples of side effect programming technique. Any useful programming language must provide a way to interact with side effects.Read More