Skip to content

Make osp :: QuasiQuoter valid as a pattern #205

@lawbel

Description

@lawbel

I was quite surprised to find that the following code is not valid:

import System.OsPath (OsPath, osp, takeExtension)

data Format = Png | Jpeg

extensionType :: OsPath -> Maybe Format
extensionType path = case takeExtension path of
    [osp|.png|] -> Just Png
    [osp|.jpg|] -> Just Jpeg
    _           -> Nothing

I can see that the osp QuasiQuoter is implemented to only support expressions, but this kind of use case feels very natural. Especially given that it is non-trivial to construct a valid OsPath literal.

Is there any reason why this couldn't or shouldn't be implemented? If no, then I would be more than happy to have a go at it and put together a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions