Skip to content

Commit

Permalink
Revert "Less unsafeCoerce (#322)"
Browse files Browse the repository at this point in the history
This reverts commit 5e037c0.
  • Loading branch information
matthewbauer committed Jan 31, 2020
1 parent 8064382 commit b3ad64a
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 162 deletions.
1 change: 0 additions & 1 deletion reflex.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ library
monoidal-containers == 0.4.0.0

exposed-modules:
Control.Monad.ReaderIO
Data.AppendMap,
Data.FastMutableIntMap,
Data.FastWeakBag,
Expand Down
60 changes: 0 additions & 60 deletions src/Control/Monad/ReaderIO.hs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Reflex/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module Reflex.Class
, coerceBehavior
, coerceEvent
, coerceDynamic
, coerceIncremental
, MonadSample (..)
, MonadHold (..)
-- ** 'fan' related types
Expand Down Expand Up @@ -317,10 +316,6 @@ class ( MonadHold t (PushM t)
-- | Construct a 'Coercion' for a 'Dynamic' given an 'Coercion' for its
-- occurrence type
dynamicCoercion :: Coercion a b -> Coercion (Dynamic t a) (Dynamic t b)
-- | Construct a 'Coercion' for an 'Incremental' given 'Coercion's for its
-- patch target and patch types.
incrementalCoercion
:: Coercion (PatchTarget a) (PatchTarget b) -> Coercion a b -> Coercion (Incremental t a) (Incremental t b)
mergeIntIncremental :: Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a)
fanInt :: Event t (IntMap a) -> EventSelectorInt t a

Expand All @@ -342,12 +337,6 @@ coerceEvent = coerceWith $ eventCoercion Coercion
coerceDynamic :: (Reflex t, Coercible a b) => Dynamic t a -> Dynamic t b
coerceDynamic = coerceWith $ dynamicCoercion Coercion

-- | Coerce an 'Incremental' between representationally-equivalent value types
coerceIncremental
:: (Reflex t, Coercible a b, Coercible (PatchTarget a) (PatchTarget b))
=> Incremental t a -> Incremental t b
coerceIncremental = coerceWith $ incrementalCoercion Coercion Coercion

-- | Construct a 'Dynamic' from a 'Behavior' and an 'Event'. The 'Behavior'
-- __must__ change when and only when the 'Event' fires, such that the
-- 'Behavior''s value is always equal to the most recent firing of the 'Event';
Expand Down
18 changes: 7 additions & 11 deletions src/Reflex/Profiled.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE RankNTypes #-}
-- |
-- Module:
Expand Down Expand Up @@ -152,16 +151,13 @@ instance Reflex t => Reflex (ProfiledTimeline t) where
currentIncremental (Incremental_Profiled i) = coerce $ currentIncremental i
updatedIncremental (Incremental_Profiled i) = coerce $ profileEvent $ updatedIncremental i
incrementalToDynamic (Incremental_Profiled i) = coerce $ incrementalToDynamic i
behaviorCoercion c =
Coercion `trans` behaviorCoercion @t c `trans` Coercion
eventCoercion c =
Coercion `trans` eventCoercion @t c `trans` Coercion
dynamicCoercion c =
Coercion `trans` dynamicCoercion @t c `trans` Coercion
incrementalCoercion c d =
Coercion `trans` incrementalCoercion @t c d `trans` Coercion
mergeIntIncremental = Event_Profiled . mergeIntIncremental .
coerceWith (Coercion `trans` incrementalCoercion Coercion Coercion `trans` Coercion)
behaviorCoercion (c :: Coercion a b) = case behaviorCoercion c :: Coercion (Behavior t a) (Behavior t b) of
Coercion -> unsafeCoerce (Coercion :: Coercion (Behavior (ProfiledTimeline t) a) (Behavior (ProfiledTimeline t) a)) --TODO: Figure out how to make this typecheck without the unsafeCoerce
eventCoercion (c :: Coercion a b) = case eventCoercion c :: Coercion (Event t a) (Event t b) of
Coercion -> unsafeCoerce (Coercion :: Coercion (Event (ProfiledTimeline t) a) (Event (ProfiledTimeline t) a)) --TODO: Figure out how to make this typecheck without the unsafeCoerce
dynamicCoercion (c :: Coercion a b) = case dynamicCoercion c :: Coercion (Dynamic t a) (Dynamic t b) of
Coercion -> unsafeCoerce (Coercion :: Coercion (Dynamic (ProfiledTimeline t) a) (Dynamic (ProfiledTimeline t) a)) --TODO: Figure out how to make this typecheck without the unsafeCoerce
mergeIntIncremental = Event_Profiled . mergeIntIncremental . (unsafeCoerce :: Incremental (ProfiledTimeline t) (PatchIntMap (Event (ProfiledTimeline t) a)) -> Incremental t (PatchIntMap (Event t a)))
fanInt (Event_Profiled e) = coerce $ fanInt $ profileEvent e

deriving instance Functor (Dynamic t) => Functor (Dynamic (ProfiledTimeline t))
Expand Down
1 change: 0 additions & 1 deletion src/Reflex/Pure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ instance (Enum t, HasTrie t, Ord t) => Reflex (Pure t) where
behaviorCoercion Coercion = Coercion
eventCoercion Coercion = Coercion
dynamicCoercion Coercion = Coercion
incrementalCoercion Coercion Coercion = Coercion

fanInt e = EventSelectorInt $ \k -> Event $ \t -> unEvent e t >>= IntMap.lookup k

Expand Down
Loading

0 comments on commit b3ad64a

Please sign in to comment.