|
3 | 3 | {-# LANGUAGE BlockArguments #-} |
4 | 4 | {-# LANGUAGE CPP #-} |
5 | 5 | {-# LANGUAGE DataKinds #-} |
6 | | -{-# LANGUAGE DeriveFoldable #-} |
| 6 | +{-# LANGUAGE DeriveFoldable, DeriveGeneric #-} |
7 | 7 | {-# LANGUAGE DeriveFunctor #-} |
8 | 8 | {-# LANGUAGE DeriveTraversable #-} |
9 | 9 | {-# LANGUAGE ExistentialQuantification, DuplicateRecordFields, NoFieldSelectors #-} |
|
43 | 43 | module Main (main, specMain) where |
44 | 44 |
|
45 | 45 | #if __GLASGOW_HASKELL__ >= 906 |
| 46 | +import qualified Control.Unification as FD |
| 47 | +import GHC.Generics (Generic1) |
46 | 48 | import Control.Monad |
47 | 49 | #endif |
48 | 50 |
|
@@ -2636,6 +2638,30 @@ temp_withSystemTempDirectory template action = Temp.withSystemTempDirectory (Tex |
2636 | 2638 | process_setWorkingDir :: forall a b c. Text -> ProcessConfig a b c -> ProcessConfig a b c |
2637 | 2639 | process_setWorkingDir filepath = Process.setWorkingDir (Text.unpack filepath) |
2638 | 2640 |
|
| 2641 | +-------------------------------------------------------------------------------- |
| 2642 | +-- unification-fd compatibility layer |
| 2643 | + |
| 2644 | +data Ty a |
| 2645 | + = TyApp a a |
| 2646 | + | TyFun a a |
| 2647 | + | TyCon SomeTypeRep |
| 2648 | + deriving (Functor, Traversable, Foldable, Eq, Ord, Show, Generic1) |
| 2649 | + |
| 2650 | +-- <bijection> |
| 2651 | +irep_to_uterm :: IRep v -> FD.UTerm Ty v |
| 2652 | +irep_to_uterm = \case |
| 2653 | + IVar v -> FD.UVar v |
| 2654 | + IApp f x -> FD.UTerm (TyApp (irep_to_uterm f) (irep_to_uterm x)) |
| 2655 | + IFun f x -> FD.UTerm (TyFun (irep_to_uterm f) (irep_to_uterm x)) |
| 2656 | + ICon t -> FD.UTerm $ TyCon t |
| 2657 | +uterm_to_irep :: FD.UTerm Ty v -> IRep v |
| 2658 | +uterm_to_irep = \case |
| 2659 | + FD.UVar v -> IVar v |
| 2660 | + FD.UTerm (TyApp f x) -> IApp (uterm_to_irep f) (uterm_to_irep x) |
| 2661 | + FD.UTerm (TyFun f x) -> IFun (uterm_to_irep f) (uterm_to_irep x) |
| 2662 | + FD.UTerm (TyCon t) -> ICon t |
| 2663 | +-- </bijection> |
| 2664 | + |
2639 | 2665 | -------------------------------------------------------------------------------- |
2640 | 2666 | -- Inference type representation |
2641 | 2667 |
|
|
0 commit comments