> When I compile the module below with ghc-4.01
> and -fglasgow-exts, I get the following error message:
> 
> YouCantDoThat.lhs:8:
>     Kind mis-match between `_a :: *' and `Int# :: *#'
>         Expected type: _a -> Int'
>         Inferred type: Int# -> Int'
>     In the first argument of `$', namely `Int''
>     In the right-hand side of an equation for `disallowed':
>         Int' $ (a +# a)
> 
> The function @allowed@ seems perfectly ok.
> 
> > module YouCantDoThat( disallowed, allowed ) where
> 
> > import GlaExts
> 
> > data Int' = Int' Int#
> 
> > disallowed :: Int# -> Int'
> > disallowed a = Int' $ a +# a
> 
> > allowed :: Int# -> Int'
> > allowed a = Int' (a +# a)

Quite right too!  '$' has type ((a->b) -> a -> b), and the rule
is that polymorphic type variables can't be instantiated with unboxed
types.  In this case, Int#.  It's true that in this case '$' will get
inlined, so disallowed turns into allowed, but the type checker doesn't know
that.  Better to have a simple rule.


> 
> One additional comment. I frequently use quotes (') as suffixes
> for identifier and type names. As can be seen above ghc loves adding
> quotes (` and ') around parts of its messages. This becomes *very*
> confusing when the last part of the message consists of an
> identifier suffixed by a one or more quote symbols.

I've noticed this too, but the trouble is that if you leave the quotes
out then identifiers tend to get lost in the text.  Better ideas welcome.

Simon

Reply via email to