cangjie-generic

Explain Cangjie generic programming with parameterized types and where clauses.

1|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-generic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-generic
Source: https://github.com/SunriseSummer/CangjieDocValidator/tree/main/.github/skills/generic
Command: npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-generic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you understand and utilize Cangjie's powerful generic programming features, enabling you to write more flexible, reusable, and type-safe code.

Core Features & Use Cases

  • Parameterized Types: Learn how to define functions, classes, interfaces, structs, and enums that operate on types specified at usage time.
  • Generic Constraints: Understand how to enforce requirements on type parameters using the where clause, ensuring type safety.
  • Type Variance: Explore how generic types behave with respect to subtyping, including invariance, covariance, and contravariance.
  • Use Case: Implement a generic List<T> that can hold any type of element, or a generic Repository<T> that can manage data for any entity type T.

Quick Start

Explain the concept of a generic function in Cangjie with an example.

Frequently Asked Questions about cangjie-generic

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define generic functions and classes in Cangjie?

Cangjie uses parameterized types for generic functions and classes, allowing you to specify type parameters at declaration that are determined at usage time. This enables writing flexible, reusable, and type-safe code for any entity type.

How do generic constraints work in Cangjie?

Cangjie enforces generic constraints using `where` clauses to specify requirements on type parameters. This ensures type safety by restricting types that can be substituted into parameterized classes, interfaces, and functions.

What is type variance and how does it affect subtyping in Cangjie generics?

Type variance in Cangjie determines how parameterized types behave with respect to subtyping, covering invariance, covariance, and contravariance. It defines subtyping relationships for both user-defined and built-in generic types.

Can I use static members inside generic classes in Cangjie?

Cangjie addresses specific static member limitations within generic classes. These limitations apply to parameterized types to ensure type safety and predictable behavior when operating with generic class structures.

What Cangjie constructs support parameterized types besides classes?

Cangjie supports parameterized types across functions, interfaces, structs, and enums, alongside classes. This allows you to implement versatile, reusable data structures and methods that operate on types specified at usage time.