The syntax you are looking for is a case or guard argument:
You said:
if (function2 inputInt == pattern((x:xs), [1,2,3])) then
In Haskell:
testingMethod inputInt | (x:xs, [1,2,3]) <- function2 inputInt = expr
| otherwise = expr2
Or using case
and let
(or you can embed or use where
):
testingMethod inputInt =
let res = function2 inputInt
in case res of
(x:xs, [1,2,3]) -> expr
_ -> expr2
Or using view templates:
{-# LANGUAGE ViewPatterns #-}
testingMethod (function2 -> (x:xs,[1,2,3])) = expr
testingMethod _ = expr2
source
share