[GHC] #14917: Allow levity polymorhism in binding position
GHC
ghc-devs at haskell.org
Tue Mar 20 03:06:31 UTC 2018
#14917: Allow levity polymorhism in binding position
-------------------------------------+-------------------------------------
Reporter: andrewthad | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
Resolution: | Keywords:
| LevityPolymorphism
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by goldfire):
Sure we do. I have not explored ''how'' we do, but sure we do. This
program compiles and runs:
{{{#!hs
data List (b :: TYPE (TupleRep [IntRep, DoubleRep, LiftedRep])) = Nil |
Cons b (List b)
mapUbx :: forall (a :: Type) (b :: TYPE (TupleRep [IntRep, DoubleRep,
LiftedRep])). (a -> b) -> [a] -> List b
mapUbx _ [] = Nil
mapUbx f (x : xs) = Cons (f x) (mapUbx f xs)
blargh :: forall a. Int# -> Double# -> a -> (# Int#, Double#, a #)
blargh x y = (#,,#) x y
strange = mapUbx (blargh 3# 2.78##) [True, False]
printList :: Show b => List (# Int#, Double#, b #) -> IO ()
printList Nil = return ()
printList (Cons (# n, d, b #) xs) = do
print (I# n)
print (D# d)
print b
printList xs
main = do
printList strange
}}}
We probably just eta-expand `blargh`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14917#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list