I'm currently dealing with a function that goes like this:
foo = (\(a:b:c:d:e:f:_) -> foobar a b c d e f) . (++ repeat def)
In other words, given a list, it uses the first six elements for something, and if the list is less than six elements long, it uses def as a stand-in for the missing ones. This is total, but the pieces of it aren't (just like map fromJust . filter isJust), so I don't like it. I tried to rewrite this so that it doesn't need to use any partiality, and got this:
foo [] = foobar def def def def def def
foo [a] = foobar a def def def def def
foo [a,b] = foobar a b def def def def
foo [a,b,c] = foobar a b c def def def
foo [a,b,c,d] = foobar a b c d def def
foo [a,b,c,d,e] = foobar a b c d e def
foo (a:b:c:d:e:f:_) = foobar a b c d e f
I technically did what I want, but now this is a gigantic mess. How can I do this in a more elegant and less repetitive way?