Opened 10 years ago

Closed 4 years ago

#1522 closed feature request (fixed)

Make [n..] etc syntax rebindable

Reported by: guest Owned by: simonpj
Priority: lowest Milestone: 7.6.2
Component: Compiler Version: 6.6.1
Keywords: Cc: ekmett@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by igloo)

The [foo..], [foo..bar], [foo,bar..] and [foo,bar..baz] sugars do not obey -fno-implicit-prelude.

{-# OPTIONS_GHC -fno-implicit-prelude #-}
module ListSugar where

import Control.Monad
import Prelude hiding (Enum,enumFrom)

class Enum a where 
   enumFrom :: MonadPlus m => a -> m a
instance Enum Int where 
   enumFrom n = return n `mplus` enumFrom (n + 1)

main = print $ ([1..] :: Maybe Int)

ListSugar.hs:9:16:
    Couldn't match expected type `Maybe Int'
           against inferred type `[a]'
    In the expression: [1 .. ]
    In the second argument of `($)', namely `([1 .. ] :: Maybe Int)'
    In the expression: print $ ([1 .. ] :: Maybe Int)

and even with the same signature as the original type, it invokes the version in the Prelude.

Attachments (1)

ListSugar.hs (288 bytes) - added by guest 10 years ago.
example

Download all attachments as: .zip

Change History (17)

Changed 10 years ago by guest

Attachment: ListSugar.hs added

example

comment:1 Changed 10 years ago by guest

Cc: ekmett@… added

comment:2 Changed 10 years ago by igloo

Description: modified (diff)

comment:3 Changed 10 years ago by igloo

Milestone: 6.1
Summary: enumFrom* do not respect -fno-implicit-preludeMake [n..] etc syntax rebindable

comment:4 Changed 10 years ago by simonpj

Owner: set to simonpj
Type: bugfeature request

The manual does not claim that this works. It's a perfectly reasonable feature request though.

Simon

comment:5 Changed 9 years ago by simonmar

Architecture: MultipleUnknown/Multiple

comment:6 Changed 9 years ago by simonmar

Operating System: MultipleUnknown/Multiple

comment:7 Changed 8 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:8 Changed 7 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:9 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:10 Changed 6 years ago by igloo

Milestone: 7.0.17.0.2

comment:11 Changed 6 years ago by igloo

Milestone: 7.0.27.2.1

comment:12 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:13 Changed 5 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:14 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:15 Changed 4 years ago by morabbin

Type of failure: None/Unknown

This is somewhat handled by GHC extension OverloadedLists.

comment:16 Changed 4 years ago by simonpj

Resolution: fixed
Status: newclosed

Yes, it is. So I'll close this ticket. Hurrah.

Note: See TracTickets for help on using tickets.