| definition:   |  
consToPolyPattern :: CConsDecl -> CPattern
consToPolyPattern (CCons name _ tes) = CPComb name pats
  where
    pats = map convert tes
    -- Converts a type expression to a pattern such that only type variables are pattern-matched (bound to a variable)
    convert te = case te of
      CTVar (i, n) -> CPVar (i, n ++ "'")
      _            -> anonPattern
    -- Replaces all recurrences of type variables in a list of type expressions with wildcards
    anonDuplicates (x:xs) | x == anonPattern = x : anonDuplicates xs
                          | otherwise        = x : anonDuplicates (substitute x anonPattern xs)
    anonDuplicates []     = []
    -- Replaces all occurrences of a type variable pattern with a wildcard pattern
    substitute v1 v2 = map (\x -> if x == v1 then v2 else x)  | 
            
            
              
              | demand:   |  argument 1 | 
            
            
              
              | deterministic:   |  deterministic operation | 
            
            
              
              | documentation:   |  
Pattern-matches the first occurrence of every type variable in a given type expression. 
For a specific constructor of a type definition 
  data T t1 ... tn = ... | C e1 ... em | ...
this function generates a pattern
 C p1 ... pm
where pi (1 <= i <= m) is...
 - a variable ei' if ei the first occurence of a polymorphic type variable t1 ... tn in the constructor
 - a wildcard _   otherwise
Example:
  data T a = C a String a [a]
  consToPolyPattern C -> C a' _ _ _ | 
            
            
              
              | failfree:   |  {CCons} | 
            
            
              
              | indeterministic:   |  referentially transparent operation | 
            
            
              
              | infix:   |  no fixity defined | 
            
            
              
              | iotype:   |  {({CCons}) |-> {CPComb}} | 
            
            
              
              | name:   |  consToPolyPattern | 
            
            
              
              | precedence:   |  no precedence defined | 
            
            
              
              | result-values:   |  {CPComb} | 
            
            
              
              | signature:   |  AbstractCurry.Types.CConsDecl -> AbstractCurry.Types.CPattern | 
            
            
              
              | solution-complete:   |  operation might suspend on free variables | 
            
            
              
              | terminating:   |  yes | 
            
            
              
              | totally-defined:   |  possibly non-reducible on same data term |