1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 21:47:07 +03:00

Define GAlign instances for Unions.

This commit is contained in:
Rob Rix 2017-05-03 15:58:27 -04:00
parent ce50d2da71
commit 1f6d044994

View File

@ -6,6 +6,7 @@ module Data.Functor.Union
, InUnion(..)
) where
import Data.Align.Generic
import Data.Functor.Classes
import Data.Kind
import GHC.Show
@ -111,3 +112,11 @@ instance (Show1 f, Show1 (Union fs)) => Show1 (Union (f ': fs)) where
instance Show1 (Union '[]) where
liftShowsPrec _ _ _ _ = identity
instance (GAlign f, GAlign (Union fs)) => GAlign (Union (f ': fs)) where
galignWith f (Here a) (Here b) = Here <$> galignWith f a b
galignWith f (There a) (There b) = There <$> galignWith f a b
galignWith _ _ _ = Nothing
instance GAlign (Union '[]) where
galignWith _ _ _ = Nothing