Skip to content

Commit

Permalink
Merge pull request #13 from 414owen/os/support-new-language-thrift
Browse files Browse the repository at this point in the history
fix: Use 'functionParameters' qualified
  • Loading branch information
phile314 authored Jul 17, 2024
2 parents 5629db5 + 3d57e83 commit 5665d45
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Pinch/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,11 @@ gFieldType f = do

gFunction :: Function SourcePos -> GenerateM (H.Name, H.Type, H.Exp, [H.Decl], [H.Decl])
gFunction f = do
argTys <- traverse (fmap snd . gFieldType) (functionParameters f)
argTys <- traverse (fmap snd . gFieldType) (A.functionParameters f)
retType <- maybe (pure tyUnit) gTypeReference (functionReturnType f)


argDataTy <- structDatatype argDataTyNm (functionParameters f)
argDataTy <- structDatatype argDataTyNm (A.functionParameters f)
let catchers = map
(\e -> H.EApp "Control.Exception.Handler"
[ H.EInfix "Prelude.." "Prelude.pure" (H.EVar $ dtNm <> "_" <> capitalize (fieldName e))
Expand Down Expand Up @@ -519,10 +519,10 @@ gFunction f = do
let clientFunTy = H.TyLam argTys (H.TyApp (H.TyCon "Pinch.Client.ThriftCall") [resultDataTy])
let callSig = H.TypeSigDecl nm $ clientFunTy
let call = H.FunBind
[ H.Match nm ( map (H.PVar . fieldName) $ functionParameters f)
[ H.Match nm ( map (H.PVar . fieldName) $ A.functionParameters f)
( H.EApp (if functionOneWay f then "Pinch.Client.TOneway" else "Pinch.Client.TCall")
[ H.ELit $ H.LString $ functionName f
, H.EApp (H.EVar argDataTyNm) $ map (H.EVar . fieldName) (functionParameters f)
, H.EApp (H.EVar argDataTyNm) $ map (H.EVar . fieldName) (A.functionParameters f)
]
)
]
Expand All @@ -542,7 +542,7 @@ gFunction f = do
where
nm = decapitalize $ functionName f
dtNm = capitalize (functionName f) <> "_Result"
argVars = take (length $ functionParameters f) $ map T.singleton ['a'..]
argVars = take (length $ A.functionParameters f) $ map T.singleton ['a'..]
argDataTyNm = capitalize $ functionName f <> "_Args"
exceptions = concat $ maybeToList $ functionExceptions f

Expand Down

0 comments on commit 5665d45

Please sign in to comment.