Using the result of a system command

10 views
Skip to first unread message

rma...@mun.ca

unread,
Jul 8, 2017, 8:39:08 AM7/8/17
to Shake build system
I have this fragment in my Build.hs:

"objects//*.o" %> \out -> do
let c = dropDirectory1 $ out -<.> "cxx"
let m = out -<.> "m"
-- let i = command [] "pkg-config" ["glib-2.0","--cflags"]
-- Stdout i <- command [] "pkg-config" ["glib-2.0","--cflags"]
Stdout i <- command [] "pkg-config" ["glib-2.0","--cflags"] :: Action
need i
() <- cmd "c++ -c" [c] "-o" [out] "-MMD -MF" [m] [i]
needMakefileDependencies m

I get this error:

Build.hs:31:72: error:
* Expecting one more argument to `Action'
Expected a type, but `Action' has kind `* -> *'
* In an expression type signature: Action
In a stmt of a 'do' block:
Stdout i <- command [] "pkg-config" ["glib-2.0", "--cflags"] ::
Action
In the expression:
do { let c = dropDirectory1 $ out -<.> "cxx";
let m = out -<.> "m";
Stdout i <- command [] "pkg-config" ["glib-2.0", ....] :: Action;
need i;
.... }

Will someone please tell me where I am going wrong?

Thanks.

Neil Mitchell

unread,
Jul 8, 2017, 8:42:31 AM7/8/17
to rma...@mun.ca, Shake build system
Hi,

The problematic line is:

Stdout i <- command [] "pkg-config" ["glib-2.0","--cflags"] :: Action

Specifically the ":: Action" bit at the end. Action is a higher-kinded
type, so you pretty much always want Action <something>. In this case
Action (Stdout String) would probably work - but I'd probably just
drop the :: Action entirely as it is probably redundant.

Thanks, Neil
Reply all
Reply to author
Forward
0 new messages