This may be safe with the current GHC implementation, but this is not the recommended way to solve your specific problem.
Instead of the template, the internal module is usually used:
module Foo.Types (T(..)) where
newtype T = T Int
This module is declared non-exportable in your Cabal file. Then, in the module in which you want to use the type, you import the module Typesand use the constructor directly:
module Foo.Bla where
import Foo.Types (T(..))
f :: T -> Bla
f (T int) = makeBla int
Finally, you can export an opaque type, but you want to. For instance:
module Foo (T) where
import Foo.Types (T(..))
makeT :: Int -> T
makeT = T
Coercion can be used instead, but it would be a bad idea to rely on it.
source
share