Skip to content

Commit

Permalink
cleanup parsing of PackageName to lessen packing/unpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
kadoban committed Nov 19, 2015
1 parent 5b97845 commit 349e5dd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Stack/Types/PackageName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ mkPackageName s =

-- | Parse a package name from a 'Text'.
parsePackageName :: MonadThrow m => Text -> m PackageName
parsePackageName =
parsePackageNameFromString . T.unpack
parsePackageName x = go x
where go =
either (const (throwM (PackageNameParseFail x))) return .
parseOnly (packageNameParser <* endOfInput)

-- | Parse a package name from a 'String'.
parsePackageNameFromString :: MonadThrow m => String -> m PackageName
parsePackageNameFromString x = go . T.pack $ x
where go =
either (const (throwM (PackageNameParseFail (T.pack x)))) return .
parseOnly (packageNameParser <* endOfInput)
parsePackageNameFromString =
parsePackageName . T.pack

-- | Produce a string representation of a package name.
packageNameString :: PackageName -> String
Expand Down

0 comments on commit 349e5dd

Please sign in to comment.