Prelude> let myprint = putStrLn . show
Prelude> :t myprint
myprint :: () -> IO ()
OK, nothing too unusual here. Just GHCi type defaulting rule
We can do the following, with monomorphism restriction on:
>let myprint :: Show x => x -> IO (); myprint = putStrLn . show
>:t myprint
myprint :: Show x => x -> IO ()
This is not the same as let myprint = putStrLn . show :: Show x => x -> IO ()
. In the former case we have a binding with a type signature, in the latter case we a have a let
binding with a type annotation inside the right hand side. Monomorphism checks top-level type signatures, but not local annotations.