One of my fondest memories of the Rep’s main house is of seeing Alan Ayckbourn’s A Small Family Business here in 1989.

It was written for the National Theatre a couple of years earlier, and the physical demands of its set mean that very few stages can do it justice. But while it is very entertaining in Ayckbourn’s familiar comic style, it could also be argued that it is a great play.

The greatness lies in the classical inevitability of its tragedy, as its chief protagonist, a well-meaning builder, is dragged down by the greed and dishonesty of those around him.

Comedy and personal tragedy are perfectly fused within a picture of Britain nearing the end of the Thatcher era.

I mention this here because Woman in Mind, from 1985, is the play which immediately preceded it ­and the contrast is striking. This has none of the structural elegance of its successor: in fact, it’s a bit of a mess.

Woman in Mind is often cited as a radical departure for Ayckbourn, which is obviously true. Always experimenting with theatrical space, here he has looked for it within the mind of his central character, Susan, one of the many frustrated women who abound in his plays. And the darkness which had previously lurked at the edges of his plays is here brought centre stage.

Susan is trapped in a stale marriage with Gerald, a dull and pompous vicar whose main preoccupation is the interminable booklet he is writing on the history of his parish. They are estranged from their only child, Rick, who has joined a cult which explicitly forbids its members to speak to their parents.

Her escape is to create a fantasy world in which her small garden is expanded into a rambling estate and her dysfunctional family is replaced by a loving and attentive husband, daughter and brother from a markedly higher social class.

An immediate problem is that this Arcadian fantasy and the people who populate it are too insipid to engage much interest or sympathy. But as Susan’s mental crisis deepens her invented family begins to take on a more independent and sinister character, wrestling control from her and blurring the line between fantasy and reality.

While I am no expert, I doubt this has very much to do with the reality of a nervous breakdown. What I think is going on (and I admit I did struggle) is that Ayckbourn the theatrical craftsman is cutting and pasting genres, so that we have something which is part ghost story and part Lewis Carroll, as Susan shreds the unexpected developments following Rick’s return and finally jumbles them up into a nightmare involving all the characters, both real and imaginary.

Throughout, he keeps a comic foot on the ground through a laboured running joke about Gerald’s sister’s terrible cooking.

It is a bemusing mixture which demonstrates how hit ­and ­miss Ayckbourn’s work became once he moved beyond the relatively realistic suburban idiom which made his name in the 1970s.

This co­-production with Dundee Rep sets itself some high production values. In a daunting role, and in a cast which generally ticks boxes rather than excels, Meg Fraser does her best to infuse the stubbornly uninteresting Susan with plausible life.

Ti Green’s set, incorporating a small forest and a boxed secondary stage, has great aesthetic appeal, even though the use to which the latter is put amounts to little.

The thunder storm in which Susan is found lying on the lawn (King Lear added to Ayckbourn’s other references) is effectively evoked without recourse to gallons of water.

One stunning moment, when the set is suddenly transformed, post-­storm, by a burst of brilliant sunshine, ought to clinch an award for lighting designer Mark Doubleday.

Runs until June 28.