Example. 程式作為natural transformation [631K]

如果一些類型構成category,可以用functor表示參數化類型。例如我們可以定義natural transformation α:Maybe→List\alpha : \text{Maybe} \to \text{List} 為

αX:Maybe(X)→List(X)αX(Nothing)=[]αX(Some x)=[x]\begin{aligned} &\alpha_X : \text{Maybe}(X) \to \text{List}(X) \\ &\alpha_X(\text{Nothing}) &= [] \\ &\alpha_X(\text{Some}\ x) &= [x] \end{aligned}
figure tex7646

或是取出List中的最大值

figure tex7647