Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. data Skolem (s :: Nat) = forall a. Skolem a
  2.  
  3. unsafeUnskolem :: Skolem n -> a
  4. unsafeUnskolem (Skolem a) = unsafeCoerce a
  5.  
  6.  
  7. data Error e (m :: * -> *) a
  8. = Throw e
  9. | forall x. Catch (m x) (e -> m x) (x -> a)
  10.  
  11. instance Functor m => Generic (Error e m a) where
  12. type Rep (Error e m a)
  13. = D1
  14. ('MetaData "Error" "TRYAGAIN" "main" 'False)
  15. (C1
  16. ('MetaCons "Throw" 'PrefixI 'False)
  17. (S1
  18. ('MetaSel
  19. 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
  20. (Rec0 e))
  21. :+: C1
  22. ('MetaCons "Catch" 'PrefixI 'False)
  23. (S1
  24. ('MetaSel
  25. 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
  26. (Rec0 (m (Skolem 0))
  27. :*: (S1
  28. ('MetaSel
  29. 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
  30. (Rec0 (e -> m (Skolem 0)))
  31. :*: S1
  32. ('MetaSel
  33. 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
  34. (Rec0 (Skolem 0 -> a))))))
  35. from (Throw e) = M1 $ L1 $ M1 $ M1 $ K1 $ e
  36. from (Catch a b c) =
  37. M1 $ R1 $ M1 $ M1 $ K1 (fmap Skolem a)
  38. :*: M1 (K1 $ \e -> fmap Skolem $ b e)
  39. :*: M1 (K1 $ \(Skolem s) -> c $ unsafeCoerce s)
  40. to (M1 (L1 (M1 (M1 (K1 e))))) = Throw e
  41. to (M1 (R1 (M1 (M1 (K1 a :*: (M1 (K1 b)) :*: (M1 (K1 c))))))) =
  42. Catch (fmap unsafeUnskolem a)
  43. (fmap (fmap unsafeUnskolem) b)
  44. (c . unsafeUnskolem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement