Ticket #4236 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

arrow bug

Reported by: igloo Owned by: SamAnklesaria
Priority: normal Milestone: 7.0.1
Component: Compiler Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Initially reported here:  http://www.haskell.org/pipermail/glasgow-haskell-users/2010-July/019035.html

This program:

{-# LANGUAGE Arrows #-}
module Main where

import Control.Arrow

foo :: (b -> String) -> ((((b, Int), Float), Double) -> String) -> (b -> String)
foo f g b = f b ++ " " ++ g (((b, 8), 1.0), 6.0)

bar :: (t -> String) -> ((t, Double, Float, Int) -> String) -> t -> String
bar f g  = proc x -> do
  (f -< x) `foo` \n m k -> g -< (x,n,m,k)

main = do
  putStrLn $ foo show show 17
  putStrLn $ bar show show 17
  putStrLn $ foo show show 42
  putStrLn $ bar show show 42

produces the wrong output:

17 (((17,8),1.0),6.0)
17 (17,4.0e-323,1.0,4618441417868443648)
42 (((42,8),1.0),6.0)
42 (42,4.0e-323,1.0,4618441417868443648)

Note that, e.g.,

*Main GHC.Exts GHC.Prim> D# (unsafeCoerce# 4618441417868443648#)
6.0

-dcore-lint failes with multiple errors.

Change History

Changed 3 years ago by SamAnklesaria

  • owner set to SamAnklesaria

Changed 3 years ago by ross

  • status changed from new to closed
  • resolution set to fixed

The bug was in the type checker: the above program should have been rejected. It should have been the following, with the components of the input of g re-arranged:

{-# LANGUAGE Arrows #-}
module Main where

import Control.Arrow

foo :: (b -> String) -> ((((b, Double), Float), Int) -> String) -> (b -> String)
foo f g b = f b ++ " " ++ g (((b, 6.0), 1.0), 8)

bar :: (t -> String) -> ((t, Double, Float, Int) -> String) -> t -> String
bar f g  = proc x -> do
  (f -< x) `foo` \n m k -> g -< (x,n,m,k)

main = do
  putStrLn $ foo show show 17
  putStrLn $ bar show show 17
  putStrLn $ foo show show 42
  putStrLn $ bar show show 42

This version is now accepted and passes core lint. The originally reported version is now rejected.

Note: See TracTickets for help on using tickets.