Skip to content

Use unsafeCrashWith for unsafeRegex (future fromEither not Partial) + Unix line endings #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/Data/String/Regex/Unsafe.purs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module Data.String.Regex.Unsafe
( unsafeRegex
) where
import Data.Either (fromRight)
import Data.String.Regex (Regex, regex)
import Data.String.Regex.Flags (RegexFlags)
import Partial.Unsafe (unsafePartial)
-- | Constructs a `Regex` from a pattern string and flags. Fails with
-- | an exception if the pattern contains a syntax error.
unsafeRegex :: String -> RegexFlags -> Regex
unsafeRegex s f = unsafePartial fromRight (regex s f)
module Data.String.Regex.Unsafe
( unsafeRegex
) where

import Prelude (identity)
import Data.Either (either)
import Data.String.Regex (Regex, regex)
import Data.String.Regex.Flags (RegexFlags)
import Partial.Unsafe (unsafeCrashWith)

-- | Constructs a `Regex` from a pattern string and flags. Fails with
-- | an exception if the pattern contains a syntax error.
unsafeRegex :: String -> RegexFlags -> Regex
unsafeRegex s f = either unsafeCrashWith identity (regex s f)