Copied Logic.hs from HsSymMath to RegEx.hs