Haskell point free for more than one argument

52 Views Asked by At

I'm trying to achieve a point free version of the following example:

data Person = Person String Int deriving ( Show, Eq )
data Animal = Animal Person deriving ( Show, Eq )

f :: String -> Int -> Animal
f s = Animal . Person s
-- f = Animal . Person                 -- [ 1 ]
-- f = Animal $ Person                 -- [ 2 ]
-- f = Animal . (uncurry Person) . (,) -- [ 3 ]

main = print (f "ppp" 8)
  • Cancelling just the Int is easy, but I can't get rid of the string s (attempts above)
  • This is a bit weird (?), because attempt [ 1 ] simply "peels off" a rightmost s
0

There are 0 best solutions below