▁creating ▁a ▁new ▁object ▁of ▁the ▁similarly - named ▁class ▁:: , ▁the ▁class ▁of ▁non empty ▁lists .) ▁The ▁most ▁obvious ▁type ▁to ▁give ▁it ▁would ▁be ▁ ▁def ▁:: ▁( x : ▁A ): ▁List [ A ] ▁ ▁However , ▁this ▁would ▁be ▁a ▁type ▁error , ▁because ▁the ▁cov ari ant ▁parameter ▁A ▁appears ▁in ▁a ▁cont rav ari ant ▁position ▁( as ▁a ▁function ▁parameter ). ▁But ▁there ▁is ▁a ▁trick ▁to ▁get ▁around ▁this ▁problem . ▁We ▁give ▁:: ▁a ▁more ▁general ▁type , ▁which ▁allows ▁adding ▁an ▁element ▁of ▁any ▁type ▁B ▁ ▁as ▁long ▁as ▁B ▁is ▁a ▁super type ▁of ▁A . ▁Note ▁that ▁this ▁re lies ▁on ▁List ▁being ▁cov ari ant , ▁since ▁ ▁this ▁ ▁has ▁type ▁List [ A ] ▁and ▁we ▁treat ▁it ▁as ▁having ▁type ▁List [ B ]. ▁ ▁At ▁first ▁glance ▁it ▁may ▁not ▁be ▁obvious ▁that ▁the ▁generalized ▁type ▁is ▁sound , ▁but ▁if ▁the ▁programmer ▁starts ▁out ▁with ▁the ▁simpler ▁type ▁declaration , ▁the ▁type ▁errors ▁will ▁point ▁out ▁the ▁place ▁that ▁ ▁needs ▁to ▁be ▁generalized . ▁ ▁In fer ring ▁variance ▁ ▁It ▁is ▁possible ▁to ▁design ▁a ▁type ▁system ▁where ▁the ▁compiler ▁automatically ▁inf ers ▁the ▁best ▁possible ▁variance ▁annotations ▁for ▁all ▁dat atype ▁parameters . ▁However , ▁the ▁analysis ▁can ▁get ▁complex ▁for ▁several ▁reasons . ▁First , ▁the ▁analysis ▁is ▁non local ▁since ▁the ▁variance ▁of ▁an ▁interface ▁ ▁depends ▁on ▁the ▁variance ▁of ▁all ▁interfaces ▁that ▁ ▁mentions