arrows if command given too general a type
This is a reduced version of a function posted on Haskell Cafe:
{-# LANGUAGE Arrows #-}
testB :: not_bool -> (() -> ()) -> () -> not_unit
testB b f = proc () -> if b then f -< () else f -< ()
There are two problems with the type of this function
- the first argument can be anything but should be
Bool
and - the result type can be anything but should be
()
.
Yet the function is accepted by GHC.
This function can be used to define a value of arbitrary type:
anythingYouWant :: anything
anythingYouWant = testB () (const ()) ()
Here are some example calls from my machine:
ghci> anythingYouWant :: Int
1098066529
ghci> anythingYouWant :: String
""
ghci> anythingYouWant :: Char
'\1098066529'
ghci> anythingYouWant () :: ()
()
ghci> anythingYouWant () :: [()]
[()Segmentation fault
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |