cabal-version:       3.6

-- Copyright (c) Facebook, Inc. and its affiliates.

name:                mangle
version:             0.1.0.0
synopsis:            Convert C++ type signatures to their mangled form
homepage:            https://github.com/facebookincubator/hsthrift
bug-reports:         https://github.com/facebookincubator/hsthrift/issues
license:             BSD-3-Clause
license-file:        LICENSE
author:              Facebook, Inc.
maintainer:          hsthrift-team@fb.com
copyright:           (c) Facebook, All Rights Reserved
category:            FFI
build-type:          Simple
extra-doc-files:     CHANGELOG.md

description:
    Converts C++ type signatures to mangled symbol names.
    This is useful for calling C++ functions via the FFI without using
    @extern \"C\" { .. }@.

    The library can be used with Template Haskell, so you can call C++
    code directly from Haskell, e.g.

    @
    {-# LANGUAGE TemplateHaskell #-}
    ...
    import Mangle.TH
    ...
    $(mangle
      "void glog_info(const char*, int, const char*)"
      [d|
        foreign import ccall
          c_glog_info :: CString -> CInt -> CString -> IO ()
      |])
    @

source-repository head
    type: git
    location: https://github.com/facebookincubator/hsthrift.git

library
  exposed-modules:     Mangle, Mangle.TH
  default-extensions:  LambdaCase, GeneralizedNewtypeDeriving
  build-depends:
      base >=4.11.1.0 && <4.17,
      containers >=0.5.11.0 && <0.7,
      parsec ^>=3.1.13.0,
      template-haskell >=2.13 && <2.19
  default-language:    Haskell2010

executable mangle
  main-is:             Main.hs
  other-modules:       Mangle
  default-extensions:  LambdaCase, GeneralizedNewtypeDeriving
  build-depends:
      base >=4.11.1 && <4.17,
      containers >=0.5.11 && <0.7,
      parsec ^>=3.1.13.0,
      template-haskell >=2.13 && <2.19
  default-language:    Haskell2010

test-suite mangle-test
  type: exitcode-stdio-1.0
  hs-source-dirs: tests
  default-language: Haskell2010
  default-extensions: LambdaCase
  main-is: Test.hs
  build-depends:
      base,
      fb-stubs,
      hspec,
      hspec-contrib,
      mangle,
      HUnit ^>= 1.6.1
  ghc-options: -threaded -main-is Test