regexp n = frequency [ (3, regexp 0)
                     , (1, (.|.) <$> subexp <*> subexp)
                     , (2, (.>>.) <$> subexp <*> subexp)
                     , (1, zeroOrMore <$> regexp (n-1))
                     ]
    where subexp = regexp (n `div` 2)
regexp n = frequency [ (3, regexp 0)
                     , (1, (.|.) <$> subexp <*> subexp)
                     , (2, (.>>.) <$> subexp <*> subexp)
                     , (1, zeroOrMore <$> regexp (n-1))
                     ]
    where subexp = regexp (n `div` 2)
regexp n = frequency [ (3, regexp 0)
                     , (1, (.|.) <$> subexp <*> subexp)
                     , (2, (.>>.) <$> subexp <*> subexp)
                     , (1, zeroOrMore <$> regexp (n-1))
                     ]
    where subexp = regexp (n `div` 2)