I have a Haskell data constructor that defines an "API" (in a higher layer in my app), so I don't want to change it:
ViewModel = ViewModel { foo :: Entity Foo
, bar :: Entity Bar
, baz :: Entity Baz
}
and I have a function that produces lists of triples:
getViewModels :: Monad m => m [(Entity Foo, Entity Bar, Entity Baz)]
Is there a general method to uncurry ViewModel
in such a way that it consumes triples? More generally, is there a way to make ViewModel
consume n
-tuples?
I have in mind something like this when I call my code:
do
views <- getViewModels
return . fmap (uncurryN ViewModel) $ views
where N
is some natural number.