Nate came up with this idea here: Feature request: String interpolation - #9 by natefaubion
It’s a neat trick where instance chains recursively act like Semigroup appends over the first argument.
class TCName a where
functionName :: SemigroupLikeType -> a
instance first :: TCName SemigroupLikeType where
functionName :: SemigroupLikeType -> SemigroupLikeType
functionName value = value
else instance second :: TCName a => TCName (SemigroupLikeType -> a) where
functionName :: SemigroupLikeType -> (SemigroupLikeType -> a)
functionName firstSemi =
\secondSemi -> functionName (firstSemi <> secondSemi)
else instance third :: (OtherConstraintsNeeded b, TCName a) => TCName (b -> a) where
functionName :: SemigroupLikeType -> (b -> a)
functionName firstSemi =
\b -> functionName (funcFromOtherConstraints firstSemi b)