@@ -173,7 +173,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
173173 rty
174174 (vqs ++ if isIndexer block then [CppInline] else [])
175175 (convertNestedLambdas . asReturnBlock $ convertDictIndexers block)
176− return (CppComment com fn)
176+ return (CppComment com $ convertIfPrimFn ty' fn)
177177 where
178178 ty' | Just t <- ty = Just t
179179 | Just (t, _, _) <- M.lookup (Qualified (Just mn) ident) (E.names env) = Just t
@@ -223,7 +223,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
223223 (curriedName name)
224224 (farg <$> f)
225225 (Just $ CppAny [])
226− []
226+ (if length fields == 1 then [CppInline] else [])
227227 (CppBlock (fieldLambdas fs))
228228 ]
229229 else
@@ -868,3 +868,28 @@ curriedName' :: Cpp -> Cpp
868868curriedName' (CppVar name) = CppVar (curriedName name)
869869curriedName' (CppAccessor a b) = CppAccessor (curriedName' a) b
870870curriedName' cpp = cpp
871+
872+---------------------------------------------------------------------------------------------------
873+primFn :: T.Type -> ([CppType], Maybe CppType)
874+---------------------------------------------------------------------------------------------------
875+primFn = go []
876+ where
877+ go ps (T.TypeApp (T.TypeApp fn a) b) | fn == E.tyFunction,
878+ Just a' <- numType a = go (a' : ps) b
879+ go ps t | Just t' <- numType t = (ps , Just t')
880+ go _ _ = ([], Nothing)
881+ numType t@(T.TypeConstructor {}) | t == E.tyInt = Just intType
882+ numType t@(T.TypeConstructor {}) | t == E.tyNumber = Just doubleType
883+ numType t@(T.TypeConstructor {}) | t == E.tyBoolean = Just boolType
884+ numType t@(T.TypeConstructor {}) | t == E.tyChar = Just charType
885+ numType _ = Nothing
886+
887+---------------------------------------------------------------------------------------------------
888+convertIfPrimFn :: Maybe T.Type -> Cpp -> Cpp
889+---------------------------------------------------------------------------------------------------
890+convertIfPrimFn ty@(Just _) (CppNamespace ns fs) = CppNamespace ns (convertIfPrimFn ty <$> fs)
891+convertIfPrimFn (Just _) cpp@(CppFunction ('$':_) _ _ _ _) = cpp
892+convertIfPrimFn (Just ty) (CppFunction name params _ qs body)
893+ | (tys', Just rty') <- primFn ty =
894+ CppFunction name (zipWith (\(p, _) t -> (p, Just t)) params tys') (Just rty') qs body
895+convertIfPrimFn _ cpp = cpp