
Hi all I am working on D836 and have the following test case data MaybeDefault v where SetTo4 :: forall v a. (( Eq v, Show v ) => v -> MaybeDefault v -> a -> MaybeDefault [a]) GHC 7.10.1 regards the return type of SetTo4 as `MaybeDefault [a]` The question is, due to the parens, is the return type not the whole RHS? i.e. Similar to how in the signature map :: (a -> b) -> [a] -> [b] the first paramater is a single function. I am sure I am just confused here. Alan

On 18/05/15 10:57, Alan & Kim Zimmerman wrote:
Hi all
I am working on D836 and have the following test case
data MaybeDefault v where SetTo4 :: forall v a. (( Eq v, Show v ) => v -> MaybeDefault v -> a -> MaybeDefault [a])
GHC 7.10.1 regards the return type of SetTo4 as `MaybeDefault [a]`
The question is, due to the parens, is the return type not the whole RHS?
i.e. Similar to how in the signature
map :: (a -> b) -> [a] -> [b]
the first paramater is a single function.
I am sure I am just confused here.
This is the wrong analogy, since (a -> b) in map's type is in the negative position. The correct analogy would be the return type of map :: (a -> b) -> ([a] -> [b]) You could argue it both ways. (But only one of them leads to the above declaration being correct, since the function type is not an instance of MaybeDefault.) Roman

Thanks, that makes sense.
And the existing behaviour is in the compiler, so the surrounding parens
are optional and can/should be stripped (except for Api Annotations)
Alan
On Mon, May 18, 2015 at 10:11 AM, Roman Cheplyaka
On 18/05/15 10:57, Alan & Kim Zimmerman wrote:
Hi all
I am working on D836 and have the following test case
data MaybeDefault v where SetTo4 :: forall v a. (( Eq v, Show v ) => v -> MaybeDefault v -> a -> MaybeDefault [a])
GHC 7.10.1 regards the return type of SetTo4 as `MaybeDefault [a]`
The question is, due to the parens, is the return type not the whole RHS?
i.e. Similar to how in the signature
map :: (a -> b) -> [a] -> [b]
the first paramater is a single function.
I am sure I am just confused here.
This is the wrong analogy, since (a -> b) in map's type is in the negative position.
The correct analogy would be the return type of
map :: (a -> b) -> ([a] -> [b])
You could argue it both ways. (But only one of them leads to the above declaration being correct, since the function type is not an instance of MaybeDefault.)
Roman
participants (2)
-
Alan & Kim Zimmerman
-
Roman Cheplyaka