Following the answer in https://stackoverflow.com/a/26084087/8142021 I used the following haskell code to define a Modal Logic with GADTs.
data Plain
data Mod
data Formula t where
Prop :: {propName :: String} -> Formula t
Neg :: Formula t -> Formula t
Conj :: Formula t -> Formula t -> Formula t
Disj :: Formula t -> Formula t -> Formula t
Impl :: Formula t -> Formula t -> Formula t
BiImpl :: Formula t -> Formula t -> Formula t
MyModality :: Formula Mod -> Formula Mod
type PlainFormula = Formula Plain
type ModalFormula = Formula Mod
Is there a way to change the type of a PlainFormula to a ModalFormula? Since PlainFormula is a subset of Modal Formula, I tried to define the following injection but it did not work.
toModal :: PlainFormula -> ModalFormula
toModal f = f