Last active
July 21, 2019 21:47
-
-
Save Lysxia/e02e587ca1a08e5373301dc7d7f6a8be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Path = L Path | R Path | Here | |
data MPath = NotFound | Conflict | Found Path | |
type family Search a (f :: k -> Type) :: MPath where | |
-- ... | |
Search a (f :*: g) = OrPath (Search a f) (Search a g) | |
Search a (K1 i c) = Check a c | |
type family Check a c where | |
Check a a = 'Found 'Here | |
Check a b = 'NotFound | |
type family OrPath (p1 :: MPath) (p2 :: MPath) :: MPath where | |
OrPath ('Found p) 'NotFound = 'Found ('L p) | |
OrPath 'NotFound ('Found p) = 'Found ('R p) | |
OrPath 'NotFound 'NotFound = 'NotFound | |
OrPath _ _ = 'Conflict | |
class GHas (path :: Path) (part :: Type) (f :: k -> Type) where | |
ghas_ :: ... | |
instance GHas p part f => GHas ('L p) part (f :*: g) where ... | |
instance GHas p part g => GHas ('R p) part (f :*: g) where ... | |
ghas :: (Generic a, Search part (Rep a) ~ 'Found p, GHas p part f) => ... | |
ghas = ghas_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment