Skip to content

Commit

Permalink
Existential Cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
kim committed May 2, 2019
1 parent adab79f commit f2c436e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Data/Option.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

module Data.Option
( Cmd (..)
, SomeCmd (..)
, Opt (..)
, SomeOpt (..)
, Var
Expand Down Expand Up @@ -49,6 +50,13 @@ instance Buildable a => Buildable (Cmd a) where
build (Cmd exe opts) =
mconcat . intersperse " " $ Build.fromString exe : map build opts

data SomeCmd = SomeCmd FilePath [SomeOpt]
deriving Show

instance Buildable SomeCmd where
build (SomeCmd exe opts) =
mconcat . intersperse " " $ Build.fromString exe : map build opts


data Opt a where
Flag :: Text -> Opt a
Expand All @@ -70,8 +78,15 @@ instance Buildable a => Buildable (Opt a) where


data SomeOpt where
ShOpt :: Opt (Sh a) -> SomeOpt
LitOpt :: Opt Text -> SomeOpt
ShOpt :: (Buildable a, Show a) => Opt (Sh a) -> SomeOpt
LitOpt :: Opt Text -> SomeOpt

deriving instance Show SomeOpt

instance Buildable SomeOpt where
build = \case
ShOpt opt -> build opt
LitOpt opt -> build opt


newtype Var = Var Text
Expand Down

0 comments on commit f2c436e

Please sign in to comment.