Skip to content
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

last of a list of text should work, but doesn't #108

Open
bitemyapp opened this issue Sep 15, 2016 · 5 comments
Open

last of a list of text should work, but doesn't #108

bitemyapp opened this issue Sep 15, 2016 · 5 comments

Comments

@bitemyapp
Copy link
Contributor

Prelude> :t T.split (\c -> c == '.') "filename.pdf"
T.split (\c -> c == '.') "filename.pdf" :: [Text]
Prelude> last $ T.split (\c -> c == '.') "filename.pdf"

<interactive>:12:1:
    Couldn't match expected type ‘Element mono’
                with actual type ‘Element mono0’
    NB: ‘Element’ is a type function, and may not be injective
    The type variable ‘mono0’ is ambiguous
    When checking that ‘it’ has the inferred type
      it :: forall mono. Element mono
    Probable cause: the inferred type is ambiguous

<interactive>:12:8:
    Couldn't match expected type ‘MinLen (Succ nat0) mono’
                with actual type ‘[Text]’
    Relevant bindings include
      it :: Element mono (bound at <interactive>:12:1)
    In the second argument of ‘($)’, namely
      ‘T.split (\ c -> c == '.') "filename.pdf"’
    In the expression: last $ T.split (\ c -> c == '.') "filename.pdf"

What gives?

@bitemyapp
Copy link
Contributor Author

I know it's partial, but the type error is baffling. Contrast:

Prelude> import qualified Prelude
Prelude> Prelude.last $ T.split (\c -> c == '.') "filename.pdf"
"pdf"

@MaxGabriel
Copy link
Collaborator

Just off the top of my head, is it because the Text doesn't have a guaranteed minimum length, and without that last could be partial, that's why it's not compiling?

@bitemyapp
Copy link
Contributor Author

@MaxGabriel I think it's because the [] of [Text] doesn't have MinLen.

@snoyberg
Copy link
Owner

Try using a more recent version of mono-traversable, it should give a much
clearer error message. On mobile, I can't check myself right now.

On Fri, Sep 16, 2016, 12:32 AM Chris Allen [email protected] wrote:

@MaxGabriel https://github.com/MaxGabriel I think it's because the []
of [Text] doesn't have MinLen.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#108 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADBB0QzRPY_WawzMBJaHamdrHgxHaqFks5qqblSgaJpZM4J-VVK
.

@BebeSparkelSparkel
Copy link
Collaborator

This does appear to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants