
#8767: Add rules involving `coerce` to the libraries -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: task | Status: new Priority: normal | Milestone: 7.10.1 Component: | Version: 7.9 libraries/base | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: 8718 Type of failure: | Related Tickets: #2110 None/Unknown | Test Case: | tests/simplCore/should_run/T2110.hs| Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by dmcclean): I'm out of my depth here, not even sure this thread is about what I'm running in to. I want to coerce from `f (Quantity d v)` to `f v` where `f` is a functor, so that I can add up all the values without their wrappers in the way and then wrap the answer. This works a charm if I specialize `f` to `[]`, but doesn't compile ("because 'f (Quantity d v)' and 'f v' are different types") in the polymorphic version. (Full function below.) {{{ sum :: forall f d v.(Num v, Foldable f, Functor f) => f (Quantity d v) -> Quantity d v sum = coerce . Data.Foldable.sum . (\x -> x :: f v) . coerce sum :: forall d v.(Num v) => [Quantity d v] -> Quantity d v sum = coerce . F.sum . (\x -> x :: [v]) . coerce }}} Is this thread about making a workaround for that? Is the reason that it's complicated because some functors have nominal roles? (Maybe a SortedList would break if you changed out `Ord` instances under it?) Or is there more to it than that? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8767#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler