Incremental
動作確認を行なった incremental のバージョン
Main.hs
code: (hs)
{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} module Lib where
import Data.Extensible
import Data.Incremental
type Person = Record
'[ "name" >: String
, "age" >: Int
]
instance Incremental String where
type Delta String = String
diff str1 str2 =
if str1 == str2
then Nothing
else Just ""
alice :: Person
<: nil
bob :: Person
<: nil
fakeBob :: Person
<: nil
example :: IO ()
example = do
print $ diff alice bob
print $ diff alice fakeBob
print $ diff bob fakeBob
print $ diff bob bob
実行例
code: (hs)
ghci> example
Just (WrapDelta {unwrapDelta = Just ""} <: WrapDelta {unwrapDelta = Nothing} <: nil)
Just (WrapDelta {unwrapDelta = Just ""} <: WrapDelta {unwrapDelta = Just 14} <: nil)
Just (WrapDelta {unwrapDelta = Just ""} <: WrapDelta {unwrapDelta = Just 14} <: nil)
Nothing