packages feed

inline-c 0.9.1.6 → 0.9.1.7

raw patch · 3 files changed

+7/−12 lines, 3 files

Files

changelog.md view
@@ -1,3 +1,4 @@+- 0.9.1.7: Allow arbitrary number of C++ templates, see PR #141. - 0.9.1.6: Fix mistakenly unsafe call, see issue #137. - 0.9.1.5: Support multi-token types in C++ template arguments, see issue #125 and PR #126. - 0.9.1.4: Support GHC 8.10, including better C++ flags handling, see PR #121.
inline-c.cabal view
@@ -1,5 +1,5 @@ name:                inline-c-version:             0.9.1.6+version:             0.9.1.7 synopsis:            Write Haskell source files including C code inline. No FFI required. description:         See <https://github.com/fpco/inline-c/blob/master/README.md>. license:             MIT
src/Language/C/Inline/Context.hs view
@@ -284,18 +284,12 @@           Just ty -> return ty         hsTy <- forM cTys $ \cTys'  -> go (C.TypeSpecifier undefined cTys')         case hsTy of-          (a:[]) ->-            lift [t| $(symbol) $(return a) |]-          (a:b:[]) ->-            lift [t| $(symbol) '($(return a),$(return b))|]-          (a:b:c:[]) ->-            lift [t| $(symbol) '($(return a),$(return b),$(return c))|]-          (a:b:c:d:[]) ->-            lift [t| $(symbol) '($(return a),$(return b),$(return c),$(return d))|]-          (a:b:c:d:e:[]) ->-            lift [t| $(symbol) '($(return a),$(return b),$(return c),$(return d),$(return e))|]           [] -> fail $ "Can not find template parameters."-          _ -> fail $ "Find too many template parameters. num = " ++ show (length hsTy)+          (a:[]) ->+            lift $ TH.AppT <$> symbol <*> return a+          other ->+            let tuple = foldl (\tuple arg -> TH.AppT tuple arg) (TH.PromotedTupleT (length other)) other+            in lift $ TH.AppT <$> symbol <*> return tuple       C.TypeSpecifier _specs (C.TemplateConst num) -> do         let n = (TH.LitT (TH.NumTyLit (read num)))         lift [t| $(return n) |]