Created
December 5, 2022 23:19
-
-
Save Gabriella439/40ab5bc241df8d20b0a899d9da1031dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
module Example where | |
import Data.Text (Text) | |
import GHC.Generics (Generic) | |
import Dhall (ToDhall) | |
import Dhall.Diff (Diff) | |
import OldType (OldType) | |
import NewType (NewType) | |
import qualified Dhall | |
import qualified Dhall.Core as Core | |
import qualified Dhall.Diff as Diff | |
diffType :: forall a b . (ToDhall a, ToDhall b) => Diff | |
diffType = do | |
Diff.diff | |
(Core.denote (Dhall.declared (Dhall.inject @a))) | |
(Core.denote (Dhall.declared (Dhall.inject @b))) | |
main :: IO () | |
main = do | |
print (Diff.doc (diffType @OldType @NewType)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
module NewType where | |
import Data.Text (Text) | |
import Dhall (ToDhall) | |
import GHC.Generics (Generic) | |
data NewType | |
= Foo{ bar :: Text, baz :: Bool, new :: [Double] } | |
| Qux{ qyzzy :: Integer } | |
deriving (Generic, ToDhall) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
module OldType where | |
import Data.Text (Text) | |
import Dhall (ToDhall) | |
import GHC.Generics (Generic) | |
import Numeric.Natural (Natural) | |
data OldType | |
= Foo{ bar :: Text, baz :: Bool } | |
| Qux{ qyzzy :: Natural } | |
deriving (Generic, ToDhall) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
< Foo : : { + new : … | |
, … | |
} | |
| Qux : : { qyzzy : - Natural | |
+ Integer | |
} | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment