module Test.Multivariant.Types.Description where
import Test.Multivariant.Classes
import Data.Monoid ((<>))
import Data.Text.Lazy (Text)
import Data.Text.Lazy.Builder
newtype Description a b = Description { variants :: [Builder] }
getDescription :: Description a b -> [Text]
getDescription = map toLazyText . variants
instance Program Description where
step _f = Description [flush]
a ~> b = Description [da <> db | da <- variants a, db <- variants b ]
a <***> b = Description [da <> db | da <- variants a, db <- variants b ]
a <+++> b = Description (variants a ++ variants b)
instance WithCornerCases Description where
withCornerCases p _ = p
instance WithDescription Description where
withDescription (Description b) t = Description $ map ((fromLazyText t <>) . (singleton '\n' <>)) b