Skip to content

Commit

Permalink
Implement 'deepErrorX' in terms of 'spinify'
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Oct 1, 2019
1 parent c175443 commit 54d7e99
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions clash-prelude/src/Clash/XException.hs
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ class NFDataX a where
-- is defined.
deepErrorX :: HasCallStack => String -> a

default deepErrorX :: (HasCallStack, Generic a, GDeepErrorX (Rep a)) => String -> a
deepErrorX = withFrozenCallStack $ to . gDeepErrorX
default deepErrorX :: (HasCallStack, Generic a, GEnsureSpine (Rep a)) => String -> a
deepErrorX = withFrozenCallStack $ to . gEnsureSpine . errorX

-- | Determines whether any of parts of a given construct contain undefined
-- parts. Note that a negative answer does not mean its bit representation
Expand Down Expand Up @@ -852,24 +852,3 @@ instance NFDataX a => NFDataX (SG.Min a)
instance NFDataX a => NFDataX (SG.Option a)
instance NFDataX a => NFDataX (SG.Product a)
instance NFDataX a => NFDataX (SG.Sum a)

class GDeepErrorX f where
gDeepErrorX :: HasCallStack => String -> f a

instance GDeepErrorX V1 where
gDeepErrorX = errorX

instance GDeepErrorX U1 where
gDeepErrorX = const U1

instance (GDeepErrorX a) => GDeepErrorX (M1 m d a) where
gDeepErrorX e = M1 (gDeepErrorX e)

instance (GDeepErrorX f, GDeepErrorX g) => GDeepErrorX (f :*: g) where
gDeepErrorX e = gDeepErrorX e :*: gDeepErrorX e

instance NFDataX c => GDeepErrorX (K1 i c) where
gDeepErrorX e = K1 (deepErrorX e)

instance GDeepErrorX (f :+: g) where
gDeepErrorX = errorX

0 comments on commit 54d7e99

Please sign in to comment.