Narrative as active inference: an integrative account of cognitive and social functions in adaptation