1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 21:31:48 +03:00

Add HasField instances for hlists.

This commit is contained in:
Rob Rix 2016-06-16 11:52:14 -04:00
parent eb91962cbb
commit 3b8c1546a5

View File

@ -23,3 +23,12 @@ type a :=> b = Tagged a b
-- | This has type a :=> b. When you require a to be some concrete type (and you usually will), it should be provided by context, whether using ascription, a type signature for the binding, `asTypeOf`, or some other way to allow the specific type to be inferred. -- | This has type a :=> b. When you require a to be some concrete type (and you usually will), it should be provided by context, whether using ascription, a type signature for the binding, `asTypeOf`, or some other way to allow the specific type to be inferred.
field :: b -> a :=> b field :: b -> a :=> b
field = Tagged field = Tagged
-- Instances
instance {-# OVERLAPPABLE #-} HasField fields field => HasField (notIt ': fields) field where
getField (RCons _ t) = getField t
instance {-# OVERLAPPABLE #-} HasField (field ': fields) field where
getField (RCons h _) = h