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

haskell expression containing : are fragile #125

Open
guibou opened this issue Jun 8, 2023 · 0 comments
Open

haskell expression containing : are fragile #125

guibou opened this issue Jun 8, 2023 · 0 comments

Comments

@guibou
Copy link
Owner

guibou commented Jun 8, 2023

If the haskell expression contains :, it will fail with an unprecise error.

{-# LANGUAGE QuasiQuotes #-}

import PyF

f = ([fmt|{":"}|] :: String)
[1 of 2] Compiling Main             ( P.hs, interpreted )

P.hs:5:78: error:
    • lexical error in string/character literal at end of input in haskell expression
    • In the quasi-quotation:
        [fmtTrim|{if length currentJobsList == 0 then "- Countdown until autostop: " <> show countdown else ""}|]
  |
5 | f = ([fmtTrim|{if length currentJobsList == 0 then "- Countdown until autostop: " <> show countdown else ""}|] :: String)
  |                                                                              ^
Failed, no modules loaded.

--

f = ([fmt|{show (:[])}|] :: String)

[1 of 2] Compiling Main ( P.hs, interpreted )

P.hs:5:17: error:
• parse error (possibly incorrect indentation or mismatched brackets) in haskell expression
• In the quasi-quotation: [fmt|{show (:[])}|]
|
5 | f = ([fmt|{show (:[])}|] :: String)
| ^
Failed, no modules loaded.

ghci> [fmtTrim|{1:[]}|]

<interactive>:16:14: error:
    • 
unexpected "]"
expecting "<", ">", "^" or "="
    • In the quasi-quotation: [fmtTrim|{1:[]}|]

Some ambiguity cannot be resolved, and leads to really surprisng results.

ghci> let s = [1,2,3] in [fmtTrim|{1:s}|]
"1"

Other ambiguities, could be solved by typing, but are still leading to surprising errors

ghci> let s = [1,2,3] in [fmtTrim|{1:s:s}|]

<interactive>:18:33: error:
    • 
unexpected ":"
expecting "}"
    • In the quasi-quotation: [fmtTrim|{1:s:s}|]
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

1 participant