Playing around in ghci
I got the following expression: unlines . map (\(a,b) -> show a ++ " " ++ show b)
Now when I check it via :t
I get:
> :t unlines . map (\(a,b) -> show a ++ " " ++ show b)
unlines . map (\(a,b) -> show a ++ " " ++ show b)
:: (Show a, Show a1) => [(a, a1)] -> String
So exactly as expected. But now if I try to assign it to some name, I get a more specific signature than the original one:
> let f = unlines . map (\(a,b) -> show a ++ " " ++ show b)
> :t f
f :: [((), ())] -> String
Why does this happen?
Does your signature really have to be your actual name, or can it be something else entirely? If you need a legal opinion, you should consult an attorney, but, generally speaking, your signature can be whatever you want it to be.
Your signature should not be exactly the same each time you write. That is a sign of forgery. But it should appear very similar, with certain key characteristics, such as letters you loop and letters you don't — and it should be unique — not like anybody else's signature.
A legally binding signature makes an agreement official once all parties have placed their signatures on a contract. Signatures are the most common method of indicating that you have read over and agreed to the terms, even if a person's signature is so stylized and unique that's illegible.
A signature on a contractual document or other written agreement, demonstrates that a party has read, understood and consents to the terms and conditions in a contract. A party to an agreement is bound by his signature, regardless of whether he has actually read the contract or not.
Because of the monomorphism restriction, definitions of the form x = ...
(no parameters) are given a monomorphic (i.e. non-polymorphic) type, which usually involves some defaulting as mentioned in the other answer.
To prevent this from happening, either add a type signature to your definition, or disable the monomorphism restriction using :set -XNoMonomorphismRestriction
. You can add this to your .ghci
file to have it run automatically on startup until it gets disabled by default in GHCi in some future version.
Defaulting rules.
When you type stuff in GHCi, it attempts to apply default types. IIRC, for things with a Num
constraint it picks Integer
, for Fractional
it picks Double
, and for everything else it picks ()
.
If you write this in a Haskell source file and load it into GHCi, this doesn't happen (I believe).
I think you can also say something like default Int
to change the defaulting rules on a per-module basis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With