{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
module LiveCoding.Migrate.Monad.Trans where
import Data.Data
import LiveCoding.Cell.Monad.Trans
import LiveCoding.Migrate.Migration
maybeMigrateToState
:: (Typeable stateInternal', Typeable stateInternal)
=> State stateT stateInternal
-> stateInternal'
-> Maybe (State stateT stateInternal)
maybeMigrateToState State { stateT } stateInternal' = do
stateInternal <- cast stateInternal'
return State { .. }
migrationToState :: Migration
migrationToState = migrationTo2 maybeMigrateToState
maybeMigrateFromState
:: (Typeable stateInternal', Typeable stateInternal)
=> State stateT stateInternal
-> Maybe stateInternal'
maybeMigrateFromState State { stateInternal } = cast stateInternal
migrationFromState :: Migration
migrationFromState = constMigrationFrom2 maybeMigrateFromState
migrationState :: Migration
migrationState = migrationToState <> migrationFromState