@@ -25,10 +25,7 @@ import Data.List.NonEmpty (NonEmpty(..))
2525import qualified Data.List.NonEmpty as NEL
2626import qualified Data.Map.Strict as Map
2727import Data.Maybe (fromMaybe)
28−import Data.Proxy (Proxy (..))
29−import Data.Typeable (TypeRep, Typeable, typeRep)
3028import GHC.Generics(Generic)
31−import qualified GHC.Generics as Generics
3229import Data.Typeable (Typeable)
3330import qualified Data.Dependent.Map as DM
3431import Data.Dependent.Map (DMap)
@@ -42,9 +39,6 @@ data Provenance
4239
4340class Breakdown x where
4441 breakdown :: x -> NonEmpty Dynamic
45−-- default breakdown :: Typeable x => x -> NonEmpty Dynamic
46−-- breakdown = pure . toDyn
47−
4842
4943-- | Can't be built up from parts
5044newtype Atom x = Atom { unAtom :: x }
@@ -55,15 +49,15 @@ newtype Compound x = Compound { unCompound :: x }
5549-- | so, this is quite tricky. we need to witness the structure of `x`, but
5650-- we don't have an example of it yet. not entirely sure where to go.
5751instance (Typeable x, Generic x) => BuildFrom (Compound x) where
58− buildFrom stash = error "oops"
52+ buildFrom _stash = error "oops"
5953-- breakdown = Map.fromListWith (<>) . fmap ((dynTypeRep &&& (\x -> NEL.fromList [x])) . toDyn . Generics.to) . _ . Generics.from
6054
61−-- | this should be a bit more tractable.
62−instance (Typeable x, Generic x) => Breakdown (Compound x) where
63− breakdown x = _ . Generics.from . unCompound $ x
55+-- -- | this should be a bit more tractable.
56+-- instance (Typeable x, Generic x) => Breakdown (Compound x) where
57+-- breakdown x = _ . Generics.from . unCompound $ x
6458
6559instance Typeable x => BuildFrom (Atom x) where
66− buildFrom = Map.lookup (typeRep (Proxy @x))
60+ buildFrom = DM.lookup R.typeRep . getStash
6761
6862newtype StashValue a = StashValue { getStashValue :: NonEmpty ([Provenance], a) }
6963 deriving (Functor, Show)
@@ -79,21 +73,11 @@ instance Show Stash where
7973
8074class Typeable x => BuildFrom (x :: Type) where
8175 buildFrom :: Stash -> Maybe (StashValue x)
82− default buildFrom :: Stash -> Maybe (StashValue x)
83− buildFrom = DM.lookup R.typeRep . getStash
84−
85− -- (fmap promisedDyn . NEL.toList) . Map.lookup (typeRep (Proxy @x))
86−
87−
88−-- baseLookup :: TypeRep -> Stash -> Maybe (NonEmpty ([Provenance], Dynamic))
89−-- baseLookup tr mmm = -- Map.lookup (typeRep (Proxy @x)) mmm
90−-- Map.lookup tr mmm
9176
9277-- | only use this when we are using the internal typerep map.
9378promisedDyn :: Typeable a => Dynamic -> a
9479promisedDyn = fromMaybe (error "internal error, typerep map misconstructed") . fromDynamic
9580
96−-- instance BuildFrom Bool
9781deriving via (Atom Bool) instance BuildFrom Bool
9882
9983instance (Typeable x, BuildFrom x) => BuildFrom (Maybe x) where