Created
March 28, 2018 23:46
-
-
Save mstksg/16b3dce301d0c3794dc37f146ae6217b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE TypeFamilyDependencies #-} | |
| {-# LANGUAGE TypeInType #-} | |
| data These a b = Neither | |
| | This a | |
| | That b | |
| | These a b | |
| type family ToThese (a :: Maybe k) (b :: Maybe j) = (c :: These k j) where | |
| ToThese 'Nothing 'Nothing = 'Neither | |
| ToThese ('Just a) 'Nothing = 'This a | |
| ToThese 'Nothing ('Just b) = 'That b | |
| ToThese ('Just a) ('Just b) = 'These a b | |
| type family ToThese' (ab :: (Maybe k, Maybe j)) = (c :: These k j) | c -> ab where | |
| ToThese' '( 'Nothing, 'Nothing) = 'Neither | |
| ToThese' '( 'Just a , 'Nothing) = 'This a | |
| ToThese' '( 'Nothing, 'Just b ) = 'That b | |
| ToThese' '( 'Just a , 'Just b ) = 'These a b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment