{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Clash.Class.HasDomain.Common
( Unlines
, (:<<>>:)
, (:$$$:)
, (:++:)
, ToEM
) where
import GHC.TypeLits (Symbol)
import Type.Errors
(ErrorMessage(Text, ShowType, (:<>:), (:$$:)))
type family ToEM (k :: t) :: ErrorMessage where
ToEM (k :: Symbol) = 'Text k
ToEM (k :: ErrorMessage) = k
ToEM (k :: t) = 'ShowType k
infixl 5 :<<>>:
type (:<<>>:) (k1 :: t1) (k2 :: t2) = ToEM k1 ':<>: ToEM k2
infixl 4 :$$$:
type (:$$$:) (k1 :: t1) (k2 :: t2) = ToEM k1 ':$$: ToEM k2
type family Unlines (ln :: [k]) :: ErrorMessage where
Unlines '[] = 'Text ""
Unlines ((x :: Symbol) ': xs) = 'Text x ':$$: Unlines xs
Unlines ((x :: ErrorMessage) ': xs) = x ':$$: Unlines xs
infixl 4 :++:
type family (:++:) (as :: [k]) (bs :: [k]) :: [k] where
(:++:) a '[] = a
(:++:) '[] b = b
(:++:) (a ': as) bs = a ': (as :++: bs)