[GHC] #14112: bang patterns on pattern synonyms? (left vs right hand sides)
GHC
ghc-devs at haskell.org
Mon Aug 14 17:29:22 UTC 2017
#14112: bang patterns on pattern synonyms? (left vs right hand sides)
-------------------------------------+-------------------------------------
Reporter: carter | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
| PatternSynonyms
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 carter):
well, my first question is: how do i validate that this bang pattern?
i've looked at the core this generates, and it looks like im only getting
strictness when i'm matching on the `Just`
and not when i'm using it as a constructor!
or maybe i'm not reading the Just constructor code correclty
{{{
-- RHS size: {terms: 5, types: 9, coercions: 0, joins: 0/0}
$bJust1_r1wL
:: forall a. a -> Data.Unboxed.Maybe.R:MaybeLiftedRepa a
[GblId, Arity=1, Caf=NoCafRefs]
$bJust1_r1wL
= \ (@ a_a1zx) (a1_a1xs :: a_a1zx) ->
break<5>(a1_a1xs)
Data.Unboxed.Maybe.MaybeSum
@ a_a1zx
(GHC.Prim.(#_|#)
@ 'LiftedRep @ ('TupleRep '[]) @ a_a1zx @ (# #) a1_a1xs)
}}}
plus the casing encoding
{{{
-- RHS size: {terms: 17, types: 31, coercions: 2, joins: 0/0}
Data.Unboxed.Maybe.$mJust
:: forall (r :: TYPE rep) a.
Maybe a -> (a -> r) -> (Void# -> r) -> r
[GblId, Arity=3]
Data.Unboxed.Maybe.$mJust
= \ (@ (rep_a1zm :: RuntimeRep))
(@ (r_a1zn :: TYPE rep_a1zm))
(@ a_a1xr)
(scrut_a1zo :: Maybe a_a1xr)
(cont_a1zp :: a_a1xr -> r_a1zn)
_ [Occ=Dead] ->
break<2>(scrut_a1zo,cont_a1zp)
case scrut_a1zo
`cast` (Data.Unboxed.Maybe.D:R:MaybeLiftedRepa0[0] <a_a1xr>_N
:: (Maybe a_a1xr :: *)
~R#
(Data.Unboxed.Maybe.R:MaybeLiftedRepa a_a1xr :: *))
of
{ MaybeSum ds_d1zX ->
case ds_d1zX of {
(#_|#) a1_X1y7 -> cont_a1zp a1_X1y7;
(#|_#) ipv_s1A5 ->
Control.Exception.Base.patError
@ rep_a1zm @ r_a1zn "src/Data/Unboxed/Maybe.hs:37:19-37|case"#
}
}
}}}
latter seems like the "usual" eliminator form, as far as I can tell. I am
confused about the exception throwing element of pattern synonyms, is that
generally case?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14112#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list