From 1bccb65919e7603558313975f701626e628e6d19 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Fri, 20 Jul 2018 18:04:25 +0100 Subject: [PATCH] Erl fix ffi warning --- src/Language/PureScript/CodeGen/Erl.hs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Language/PureScript/CodeGen/Erl.hs b/src/Language/PureScript/CodeGen/Erl.hs index a2e3920d27..ee45d058a5 100644 --- a/src/Language/PureScript/CodeGen/Erl.hs +++ b/src/Language/PureScript/CodeGen/Erl.hs @@ -312,9 +312,11 @@ moduleToErl env (Module _ _ mn _ _ _ foreigns decls) foreignExports foreignTypes guard bs (ge, e) = do var <- freshNameErl ge' <- valueToErl ge - let fun = EFunFull Nothing - [(EFunBinder bs Nothing, ge'), - (EFunBinder (replicate (length bs) (EVar "_")) Nothing, boolToAtom False)] + let binder = EFunBinder bs Nothing + fun = EFunFull Nothing + ((binder, ge') : + if irrefutable binder then [] + else [(EFunBinder (replicate (length bs) (EVar "_")) Nothing, boolToAtom False)]) cas = EApp fun vals e' <- valueToErl e pure ([EVarBind var cas], (EFunBinder bs (Just $ Guard $ EVar var), e')) @@ -327,8 +329,10 @@ moduleToErl env (Module _ _ mn _ _ _ foreigns decls) foreignExports foreignTypes args' <- mapM (binderToErl' vals) es let cas binder = EApp (EFunFull Nothing - [(binder, EApp (EAtomLiteral $ Atom (Just "array") "to_list") [EVar x]), - (EFunBinder (replicate (length vals) (EVar "_")) Nothing, EAtomLiteral $ Atom Nothing "nil")]) vals + ((binder, EApp (EAtomLiteral $ Atom (Just "array") "to_list") [EVar x]) : + if irrefutable binder then [] + else [(EFunBinder (replicate (length vals) (EVar "_")) Nothing, EAtomLiteral $ Atom Nothing "nil")])) + vals var <- freshNameErl let arr = EArrayLiteral (map fst args') @@ -341,3 +345,8 @@ moduleToErl env (Module _ _ mn _ _ _ foreigns decls) foreignExports foreignTypes binderToErl' vals (NamedBinder _ ident binder) = do (e, xs) <- binderToErl' vals binder pure (EVarBind (identToVar ident) e, xs) + + irrefutable (EFunBinder bindEs Nothing) = all isVar bindEs + where isVar (EVar _) = True + isVar _ = False + irrefutable _ = False \ No newline at end of file