Created
December 5, 2022 23:19
-
-
Save Gabriella439/40ab5bc241df8d20b0a899d9da1031dc to your computer and use it in GitHub Desktop.
Revisions
-
Gabriella439 created this gist
Dec 5, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ {-# 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 hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ {-# 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 hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ {-# 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 hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ < Foo : : { + new : … , … } | Qux : : { qyzzy : - Natural + Integer } >