{-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-} import Data.List (partition) main :: IO () main = do let foo = Foo "foo" 0 Foo' msg l = foo print msg print l data Foo = Foo String Int pattern Foo' :: String -> Int -> Foo pattern Foo' s i <- (f -> (s, i)) f :: Foo -> (String, Int) f (Foo s i) = (s, i + length s) -- can I simplify this pattern synonym and avoid f being a top level function? I would like to write something like -- pattern Foo' :: String -> Int -> Foo -- pattern Foo' s i <- (f -> (s, i)) -- where -- f (Foo s i) = (s, i + length s)