haskell - Constrained heterogeneous list -
i searched hackage , couldn't find following seems simple , useful. there library contains sort of data type?
data hlist c (:-) :: c => -> hlist c nil :: hlist c all hlists found have type, , weren't constrained.
if there isn't i'll upload own.
i'm not sure data type useful...
if want
aexistentially qualified, think should use regular lists. more interesting data type hereexists, although i'm there variants of onpackagehackage already:data exists c exists :: c => -> exists cthen,
hlist cisomorphic[exists c], can still use of usual list based functions.on other hand, if don't want
ain(:-) :: c => -> hlist cexistentially qualified (having such sort of defies point ofhlist), should instead define following:data hlist (as :: [*]) (:-) :: -> hlist -> hlist (a ': as) nil :: hlist '[]then, if want require entries of
hlistsatisfyc, can make type class witness injectionhlist as[exists c]instance resolution works if types inhlistsatisfy constraint:class forallc c aslist :: hlist -> [exists c] instance forallc '[] c aslist nil = [] instance (c a, forallc c) => forallc (a ': as) c aslist (x :- xs) = exists x : aslist xs
Comments
Post a Comment