▁to ▁en force ▁that ▁a ▁C # ▁method ▁access es ▁a ▁collection ▁in ▁a ▁read - only ▁way , ▁one ▁can ▁use ▁the ▁interface ▁▁ ▁instead ▁of ▁passing ▁it ▁an ▁array ▁. ▁ ▁Function ▁types ▁ ▁L anguages ▁with ▁first - class ▁functions ▁have ▁function ▁types ▁like ▁" a ▁function ▁expecting ▁a ▁Cat ▁and ▁returning ▁an ▁Animal " ▁( written ▁ ▁in ▁O C aml ▁syntax ▁or ▁ ▁in ▁C # ▁syntax ). ▁ ▁Those ▁languages ▁also ▁need ▁to ▁specify ▁when ▁one ▁function ▁type ▁is ▁a ▁sub type ▁of ▁another — that ▁is , ▁when ▁it ▁is ▁safe ▁to ▁use ▁a ▁function ▁of ▁one ▁type ▁in ▁a ▁context ▁that ▁expects ▁a ▁function ▁of ▁a ▁different ▁type . ▁ ▁It ▁is ▁safe ▁to ▁substitute ▁a ▁function ▁f ▁for ▁a ▁function ▁g ▁if ▁f ▁accepts ▁a ▁more ▁general ▁type ▁of ▁argument ▁and ▁returns ▁a ▁more ▁specific ▁type ▁than ▁g . ▁For ▁example , ▁functions ▁of ▁type ▁, ▁ ▁, ▁and ▁ ▁can ▁be ▁used ▁wherever ▁a ▁ ▁was ▁expected . ▁( One ▁can ▁compare ▁this ▁to ▁the ▁robust ness ▁principle ▁of ▁communication : ▁" be ▁liberal ▁in ▁what ▁you ▁accept ▁and ▁conserv ative ▁in ▁what ▁you ▁produce .") ▁The ▁general ▁rule ▁is : ▁▁ ▁if ▁ ▁and ▁. ▁▁ ▁Using ▁inference ▁rule ▁notation ▁the ▁same ▁rule ▁can ▁be ▁written ▁as : ▁ ▁In ▁other ▁words , ▁the ▁→ ▁type ▁constructor ▁is ▁cont rav ari ant ▁in ▁the ▁input ▁type ▁and ▁cov ari ant ▁in ▁the ▁output ▁type . ▁This ▁rule ▁was ▁first ▁stated ▁formally ▁by