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

Issues using List/map + dhall-format #59

Closed
purcell-nec opened this issue Nov 27, 2017 · 6 comments
Closed

Issues using List/map + dhall-format #59

purcell-nec opened this issue Nov 27, 2017 · 6 comments

Comments

@purcell-nec
Copy link

Probably doing something stupid here, but given the following:

in  let envToStr = λ(e : { name : Text, val : Text }) → e.name ++ "=" ++ e.val

in  let List/map =
          https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/map 

in  let toEnv =
            λ(es : List { name : Text, val : Text })
          → List/map { name : Text, val : Text } Text envToStr es

then dhall-format converts List/map on the last line to List /map, and I get Error: Missing file. dhall-format doesn't munge List/head in the same way, which is odd.

If I disable dhall-format then I get the same error, though.

Using dhall 1.8 from stackage nightly 2017-11-25, on MacOS.

@Gabriella439
Copy link
Contributor

I believe Dhall's parser used to support this in older versions but doesn't any longer once I standardized the grammar. Like you noticed, List/map is a valid parse for List applied to the file /map and that parse takes priority over parsing it as a single variable name. In fact, I think some examples in the tutorial use this idiom and they need to be fixed

Normally you would fix this using a lexer with a longest-match rule, but the Dhall language cannot support a separate lexing step because some language features fundamentally conflict with lexing (specifically: nested block comments and string interpolation).

You can work around this by just prefixing the variable name with anything like Prelude/List/map, or just calling it map

@purcell-nec
Copy link
Author

Ah, thanks - that works. I was going off the examples at https://hackage.haskell.org/package/dhall-1.8.0/docs/Dhall-Tutorial.html#g:20, fyi.

@Gabriella439
Copy link
Contributor

I'll reopen this just to remind myself to fix the tutorial examples

@Gabriella439 Gabriella439 reopened this Nov 28, 2017
@Gabriella439
Copy link
Contributor

Fixed by dhall-lang/dhall-haskell@834c1b6

Gabriella439 added a commit that referenced this issue Feb 3, 2018
The purpose of this change is to permit identifiers that begin with
reserved keywords.  Here are some example issues due to Dhall
previously not supporting that:

* dhall-lang/dhall-haskell#250
* #59

After this change, names like `List/map` or `TypeSynonym`
would become legal.  However, this should not break any
existing code because variable names will still reject reserved
identifiers.
@Gabriella439
Copy link
Contributor

It turns out that there might be a way to fix the original issue after all to support identifier names like List/map. See: #83

@purcell-nec
Copy link
Author

Nice!

Gabriella439 added a commit that referenced this issue Feb 7, 2018
The purpose of this change is to permit identifiers that begin with
reserved keywords.  Here are some example issues due to Dhall
previously not supporting that:

* dhall-lang/dhall-haskell#250
* #59

After this change, names like `List/map` or `TypeSynonym`
would become legal.  However, this should not break any
existing code because variable names will still reject reserved
identifiers.
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

2 participants