CurryInfo: rw-data-generator-2.0.0 / RW.Build.consToPolyPattern

definition: Info
 
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: Info
 argument 1
deterministic: Info
 deterministic operation
documentation: Info
 
| 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` (with `1 <= i <= m`) is...
  - a variable `ei'` if `ei` is 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: Info
 {CCons}
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {({CCons}) |-> {CPComb}}
name: Info
 consToPolyPattern
precedence: Info
 no precedence defined
result-values: Info
 {CPComb}
signature: Info
 AbstractCurry.Types.CConsDecl -> AbstractCurry.Types.CPattern
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 yes
totally-defined: Info
 possibly non-reducible on same data term