Check dflags for language extensions when deciding if "foreign " and "deriving…

Authored by cactus.