You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Haskell, generic programming can be done in several ways:
by deriving GHC.Generics.Generic, writing instances on the Rep, and converting between Rep a and a at runtime
by using TemplateHaskell's reify to obtain the definition of a datatype, and generating the appropriate code at compile-time
by deriving Data.Data, and writing functions which match on the type of the fields at runtime
I propose to use a different way:
4. by using a type-aware macro to match on Rep a, and generating the appropriate code at compile-time
This either requires:
adding a built-in type-pattern which would look like (datatype "Person" (list (datatype-constructor "person" 'person))), where 'person can be used in the generated code as a value of type (-> String Integer (Person)), so that another type-aware macro may match on that type.
implementing monotonously-increasing maps #168, then defining the datatype type-pattern in #lang prelude so that it looks up the relevant information in a MonoMap in order to implement the above pattern, and also extend the datatype declaration to fill up that MonoMap.
The text was updated successfully, but these errors were encountered:
In Haskell, generic programming can be done in several ways:
GHC.Generics.Generic
, writing instances on the Rep, and converting betweenRep a
anda
at runtimereify
to obtain the definition of a datatype, and generating the appropriate code at compile-timeData.Data
, and writing functions which match on the type of the fields at runtimeI propose to use a different way:
4. by using a type-aware macro to match on
Rep a
, and generating the appropriate code at compile-timeThis either requires:
(datatype "Person" (list (datatype-constructor "person" 'person)))
, where'person
can be used in the generated code as a value of type(-> String Integer (Person))
, so that another type-aware macro may match on that type.datatype
type-pattern in #lang prelude so that it looks up the relevant information in a MonoMap in order to implement the above pattern, and also extend thedatatype
declaration to fill up that MonoMap.The text was updated successfully, but these errors were encountered: