-
Notifications
You must be signed in to change notification settings - Fork 39
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
UnicodeSyntax support #93
Comments
right! I added some basics now, but there are some more missing. |
Thank you for the quick reaction. Yeah, those are probably the most important, nice. Here is the list of all symbols, not so many are missing: https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/unicode_syntax.html |
yep, already have that tab open 😉 |
Thanks in advance. I wish I could help solve and not merely report the issue. But I'm getting errors when I simply use unicode characters in/as identifiers. Possibly helpful links:
Example below, and please, don't judge me for the quality of this code. It's my first Haskell program, and it's fit for a very specific purpose which is not production. (It mirrors a theoretical construction in my PhD thesis in systems theory.) {-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE UnicodeSyntax #-}
module PrAlgebra where
import Data.Fix (Fix (Fix), foldFix, unFix)
(▽) :: (a → c) → (b → c) → Either a b → c
(▽) = either
(△) :: (b → c) → (b → c') → b → (c, c')
(△) f g x = (f x, g x)
newtype 𝘗ᵣ hd tl = Pᵣ (Maybe (tl, hd))
instance Functor (𝘗ᵣ hd) where
fmap :: (a → b) → 𝘗ᵣ hd a → 𝘗ᵣ hd b
fmap f (Pᵣ Nothing) = Pᵣ Nothing
fmap f (Pᵣ (Just (tl, hd))) = Pᵣ (Just (f tl, hd))
type 𝘗ᵣAlgebra state value = 𝘗ᵣ value state → state
type Snoc hd = Fix(𝘗ᵣ hd)
snoc :: Snoc a → a → Snoc a
snoc xs x = Fix (Pᵣ (Just (xs, x))) In terms of syntax highlighting, everything is coloured as a type. Here is a screenshot where a constructor is being called a type. The tree is listed below.
|
I added three more symbols for built-in syntax. I also took a look at the symbolic operator situation, and it's a little bit more difficult. We are parsing varsyms in the scanner, which means we don't have access to the unicode category regex classes that are provided by tree-sitter. |
I am not sure, what the rules here are, but would it be terrible to over-approximate here? (Also don’t know if it would simplify things) I would assume that by allowing a larger class of unicode symbols that is maybe easier to check it would be unlikely to miss-parse valid Haskell? |
possibly, but I'm absolutely uncertain. 6k code points in a range of 130k seems quite disproportionate, and they are spaced out pretty wide. |
Your call. I would also wonder a bit how much bigger the grammar would become … |
the |
the arrow notation operators appear not to be within the categories used for the PR we just merged. also unsure about those banana brackets, they would probably need special treatment. |
I may be holding it wrong, but at least some unicode symbols are not supported as syntax:
e.g.:
gives me
The text was updated successfully, but these errors were encountered: