Skip to content

Instantly share code, notes, and snippets.

@rrnewton
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrnewton/10603049 to your computer and use it in GitHub Desktop.
Save rrnewton/10603049 to your computer and use it in GitHub Desktop.
Snippets of Int vs String IORef and basic CAS test. Spot the difference. These are both from .dump-simpl files.
case newMutVar# @ Int @ RealWorld main4 eta_Xg
of _ [Occ=Dead] { (# ipv_a7jX, ipv1_a7jY #) ->
case ({__pkg_ccall_GC atomic-primops-0.6.0.4 stg_readMutVar2zh MutVar#
RealWorld ()
-> State# RealWorld
-> (# State# RealWorld, Any () #)}_a7mV
(ipv1_a7jY
`cast` ((MutVar# <RealWorld>_N (UnivCo representational Int ()))_R
:: MutVar# RealWorld Int ~# MutVar# RealWorld ()))
ipv_a7jX)
`cast` ((# <State# RealWorld>_R,
(Any (UnivCo nominal () Int ))_R #)_R
:: (# State# RealWorld, Any () #)
~#
(# State# RealWorld, Any Int #))
of _ [Occ=Dead] { (# ipv2_X4yl, ipv3_X4yn #) ->
case ipv3_X4yn of tick1_ { __DEFAULT ->
case ({__pkg_ccall_GC atomic-primops-0.6.0.4 stg_casMutVar2zh MutVar#
RealWorld ()
-> Any ()
-> Any ()
-> State# RealWorld
-> (# State# RealWorld, Int#, Any () #)}_a7lX
(ipv1_a7jY
`cast` ((MutVar# <RealWorld>_N (UnivCo representational Int ()))_R
:: MutVar# RealWorld Int ~# MutVar# RealWorld ()))
(tick1_
`cast` ((Any (UnivCo nominal Int ()))_R :: Any Int ~# Any ()))
(main3
`cast` (UnivCo representational Int (Ticket Int)
; (Any (UnivCo nominal Int ()))_R
:: Int ~# Any ()))
ipv2_X4yl)
`cast` ((# <State# RealWorld>_R,
<Int#>_R,
(Any (UnivCo nominal () Int ))_R #)_R
:: (# State# RealWorld, Int#, Any () #)
~#
(# State# RealWorld, Int#, Any Int #))
of _ [Occ=Dead] { (# ipv4_a7j8, ipv5_a7j9, ipv6_a7ja #) ->
case ==# ipv5_a7j9 0 of _ [Occ=Dead] {
__DEFAULT -> (# ipv4_a7j8, () #);
0 ->
((failIO @ () main2)
`cast` (NTCo:IO[0] <()>_R
:: IO () ~# (State# RealWorld -> (# State# RealWorld, () #))))
ipv4_a7j8
}
}
}
}
}
case newMutVar# @ [Char] @ RealWorld old eta_Xg
of _ [Occ=Dead] { (# ipv_a7jX, ipv1_a7jY #) ->
case ({__pkg_ccall_GC atomic-primops-0.6.0.4 stg_readMutVar2zh MutVar#
RealWorld ()
-> State# RealWorld
-> (# State# RealWorld, Any () #)}_a7k3
(ipv1_a7jY
`cast` ((MutVar# <RealWorld>_N (UnivCo representational [Char] ()))_R
:: MutVar# RealWorld [Char] ~# MutVar# RealWorld ()))
ipv_a7jX)
`cast` ((# <State# RealWorld>_R,
(Any (UnivCo nominal () [Char]))_R #)_R
:: (# State# RealWorld, Any () #)
~#
(# State# RealWorld, Any [Char] #))
of _ [Occ=Dead] { (# ipv2_X4yo, ipv3_X4yq #) ->
case ipv3_X4yq of tick1_ { __DEFAULT ->
case unpackCString# "bye"# of new1_a7j2 { __DEFAULT ->
case ({__pkg_ccall_GC atomic-primops-0.6.0.4 stg_casMutVar2zh MutVar#
RealWorld ()
-> Any ()
-> Any ()
-> State# RealWorld
-> (# State# RealWorld, Int#, Any () #)}_a7j5
(ipv1_a7jY
`cast` ((MutVar# <RealWorld>_N (UnivCo representational [Char] ()))_R
:: MutVar# RealWorld [Char] ~# MutVar# RealWorld ()))
(tick1_
`cast` ((Any (UnivCo nominal [Char] ()))_R :: Any [Char] ~# Any ()))
(new1_a7j2
`cast` (UnivCo representational [] Any
(UnivCo nominal Char [Char]; UnivCo nominal [Char] ())
:: [Char] ~# Any ()))
ipv2_X4yo)
`cast` ((# <State# RealWorld>_R,
<Int#>_R,
(Any (UnivCo nominal () [Char]))_R #)_R
:: (# State# RealWorld, Int#, Any () #)
~#
(# State# RealWorld, Int#, Any [Char] #))
of _ [Occ=Dead] { (# ipv4_a7j8, ipv5_a7j9, ipv6_a7ja #) ->
case ==# ipv5_a7j9 0 of _ [Occ=Dead] {
__DEFAULT -> (# ipv4_a7j8, () #);
0 ->
((failIO @ () main2)
`cast` (NTCo:IO[0] <()>_R
:: IO () ~# (State# RealWorld -> (# State# RealWorld, () #))))
ipv4_a7j8
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment