[Haskell-cafe] Re: How to "Show" an Operation?

Martin Drautzburg Martin.Drautzburg at web.de
Fri Jun 11 01:47:03 EDT 2010

On Friday, 11. June 2010 00:12:03 Daniel Fischer wrote:

Thanks Daniel. 

> Upgrade. We're at 6.12 now!

Did that. Everything is available now.

I am still having trouble with the test function. First it seems I need 
braces, so I can mix == and <*>.
test :: Num a
     => (a -> a) -> (a -> a) -> (a -> a) -> [String]
test f g h = do
    [f', g', h'] <- permutations [Named "f" f, Named "g" g, Named "h" h]
    guard $ namedPure 42 == (f' <*> g' <*> h' <*> namedPure 42)
    return $ show f' ++ " . " ++ show g' ++ " . " ++ show h'

But this leads to

    Occurs check: cannot construct the infinite type:
      a = (a -> a) -> a1 -> t
    When generalising the type(s) for `test'

This error message is still the maximum penalty for me (along with "Corba 
marshall exception" in J2EE and "Missing right parenthesis" in Oracle SQL)

Then generally speaking, I have the feeling that this code does not 
allow "namifying" existing code either. In this respect it does not seem to 
do better than the "apply" method pattern discussed earlier in this thread.

The problem it solves is very simple and therefore using (<*>) and namedPure 
isn't much of a drawback. But if I had tons of code to namify I would still 
have to do significant changes to it, right?


More information about the Haskell-Cafe mailing list