Generic Haskell Generic Haskell is another extension to Haskell, developed at Utrecht University in the Netherlands. The extensions it provides are: Type-indexed values are defined as a value indexed over the various Haskell type constructors (unit, primitive types, sums, products, and user-defined type constructors). In addition, we can also specify the behaviour of a type-indexed values for a specific constructor using constructor cases, and reuse one generic definition in another using default cases. The resulting type-indexed value can be specialized to any type. Kind-indexed types are types indexed over kinds, defined by giving a case for both * and k → k'''. Instances are obtained by applying the kind-indexed type to a kind. Generic definitions can be used by applying them to a type or kind. This is called generic application. The result is a type or value, depending on which sort of generic definition is applied.Generic abstraction enables generic definitions be defined by abstracting a type parameter (of a given kind).Type-indexed types are types that are indexed over the type constructors. These can be used to give types to more involved generic values. The resulting type-indexed types can be specialized to any type.
GeneRic haskell gEneriC haskelL iS anothER ExtenSiOn to hAskElL, devElOped At utrEcht UniverSITy iN the nethErlands. thE eXTensIons It pRovides are: type-indexeD values are DefIneD as A VAlUe InDExEd OVer ThE various haskell type constRuctoRs (uniT, PrIMiTivE types, sUms, produCTs, ANd uSER-definEd typE cONsTRUctorS). In adDiTioN, wE can aLSo sPECIFY ThE bEHaviouR oF a type-inDeXed valUes For a spECifIC cOnSTructOr Using conStrUCtor CaSeS, anD reuSE ONe geNEric dEfiNitIOn iN anoTHEr uSing defaULt cases. thE rESulTing TypE-InDExed vALue CAn be SpecialiZEd To anY Type. kiND-indEXEd tYpEs arE tyPes inDexEd ovER kinDs, definEd bY giving a casE for bOTh * anD k → K'''. insTAnces aRe obTained by ApPLYINg the kInd-inDexed Type To a kINd. generiC dEFinitions caN Be UsEd bY ApPLYiNg ThEm tO A type Or kINd. this Is cALled gENerIc aPpLiCation. tHe rEsUlT is a TYpE or valuE, dEPENdInG oN WHicH sorT oF gEneric definITIon IS ApplIed.Generic aBStrActIOn enabLes geNeRic defInitions Be defiNed by AbsTracting a typE pArAmeTEr (of a giveN kInd).TYpe-IndeXeD TYpes are TypeS tHAt arE INdexEd OveR the Type constRuCtOrs. theSe CAn be uSeD to give tyPEs tO morE InvolvEd generIc vaLUes. the ResultiNG tYPe-indexEd types can be sPECiALiZed To ANy tyPE.