Ticket #307 (new feature request: None)

Opened 7 years ago

Last modified 3 years ago

Implicit Parameters and monomorphism

Reported by: nobody Owned by:
Priority: low Milestone: _|_
Component: None Version: None
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

http://www.haskell.org/pipermail/haskell-cafe/2005-January/008571.html

Notes some oddness with recursive binding of implicit
parameters. Roughly, giving a type signature to a
function with implicit params causes its bindings to
act recursively, despite what section 7.4.5.2 of the
user's guide says.

Change History

Changed 7 years ago by simonmar

  • summary changed from Implicit Parameter Binding to Implicit Parameters and monomorphism
Logged In: YES 
user_id=48280

This "bug" is just to record the strange interaction between
implicit parameters and monomorphism.

[adding text of original message]

Jim Apple wrote:

 > Does anyone have examples of these? This one scares the
foo out of me:
 >
 >>> * It's not even safe in general to add a signature
giving the same type
 >>> that the compiler would infer anyway

Here's an example:

    > len :: [a] -> Int
    >
    > len xs = let ?accum = 0 in len' xs
    >
    > len' [] = ?accum
    > len' (x:xs) = let ?accum = ?accum + (1::Int) in len' xs

    *Main> :t len'
    len' :: forall a. (?accum :: Int) => [a] -> Int
    *Main> len "hello"
    0

    > len :: [a] -> Int
    >
    > len xs = let ?accum = 0 in len' xs
    >
    > len' :: forall a. (?accum :: Int) => [a] -> Int
    >
    > len' [] = ?accum
    > len' (x:xs) = let ?accum = ?accum + (1::Int) in len' xs

    *Main> :t len'
    len' :: forall a. (?accum :: Int) => [a] -> Int
    *Main> len "hello"
    5

This happens as a side effect of the way that type inference
currently 
works on recursive binding groups. It happens with typeclass 
dictionaries too, but it isn't observable because they can't
be rebound 
in a local scope.

-- Ben

Changed 5 years ago by igloo

  • difficulty set to Unknown
  • milestone set to _|_
  • os set to Unknown
  • architecture set to Unknown
  • description modified (diff)

Changed 4 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 4 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 3 years ago by igloo

  • owner nobody deleted
  • status changed from assigned to new
Note: See TracTickets for help on using tickets.