yi-editor / yi

The Haskell-Scriptable Editor
GNU General Public License v2.0
1.5k stars 199 forks source link

Yi.CompletionTree #1115

Closed ghost closed 3 years ago

ghost commented 4 years ago
bash-4.3$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5
bash-4.3$ export PATH=~/.cabal/bin:${PATH}
bash-4.3$ cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library
bash-4.3$

Content of yi-core log.

bash-4.3$ cat ~/.cabal/logs/ghc-8.6.5/yi-core*
Configuring library for yi-core-0.18.0..
Preprocessing library for yi-core-0.18.0..
Building library for yi-core-0.18.0..
[ 1 of 70] Compiling Control.Exc      ( src/Control/Exc.hs, dist/build/Control/Exc.o )
[ 2 of 70] Compiling Data.DelayList   ( src/Data/DelayList.hs, dist/build/Data/DelayList.o )
[ 3 of 70] Compiling Parser.Incremental ( src/Parser/Incremental.hs, dist/build/Parser/Incremental.o )
[ 4 of 70] Compiling Paths_yi_core    ( dist/build/autogen/Paths_yi_core.hs, dist/build/Paths_yi_core.o )
[ 5 of 70] Compiling System.CanonicalizePath ( src/System/CanonicalizePath.hs, dist/build/System/CanonicalizePath.o )
[ 6 of 70] Compiling System.FriendlyPath ( src/System/FriendlyPath.hs, dist/build/System/FriendlyPath.o )
[ 7 of 70] Compiling Yi.Buffer.Implementation ( src/Yi/Buffer/Implementation.hs, dist/build/Yi/Buffer/Implementation.o )
[ 8 of 70] Compiling Yi.Buffer.Undo   ( src/Yi/Buffer/Undo.hs, dist/build/Yi/Buffer/Undo.o )
[ 9 of 70] Compiling Yi.CompletionTree ( src/Yi/CompletionTree.hs, dist/build/Yi/CompletionTree.o )

src/Yi/CompletionTree.hs:81:34-40: error:
    • Could not deduce (Ord a0) arising from a use of ‘compare’
      from the context: (Ord a, ListLike a i, Eq i)
        bound by the type signature for:
                   fromList :: forall a i.
                               (Ord a, ListLike a i, Eq i) =>
                               [a] -> CompletionTree a
        at src/Yi/CompletionTree.hs:77:1-66
      The type variable ‘a0’ is ambiguous
      These potential instances exist:
        instance Ord LL.CharString -- Defined in ‘Data.ListLike.CharString’
        instance Ord LL.CharStringLazy
          -- Defined in ‘Data.ListLike.CharString’
        instance Ord LL.Chars -- Defined in ‘Data.ListLike.Chars’
        ...plus 27 others
        ...plus 223 instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    • In the first argument of ‘on’, namely ‘compare’
      In the first argument of ‘maximumBy'’, namely
        ‘(compare `on` childrenIn xs)’
      In the expression:
        maximumBy' (compare `on` childrenIn xs) (tail $ LL.inits x)
   |
81 |   | otherwise = case maximumBy' (compare `on` childrenIn xs) (tail $ LL.inits x) of
   |                                  ^^^^^^^

src/Yi/CompletionTree.hs:88:13-82: error:
    • Non type-variable argument
        in the constraint: ListLike a1 (GHC.Exts.Item a1)
      (Use FlexibleContexts to permit this)
    • When checking the inferred type
        childrenIn :: forall a.
                      (ListLike a (GHC.Exts.Item a), Eq (GHC.Exts.Item a)) =>
                      [a] -> a -> Int
      In an equation for ‘fromList’:
          fromList (x : xs)
            | x == mempty
            = over unCompletionTree (M.insert mempty mempty) (fromList xs)
            | otherwise
            = case
                  maximumBy' (compare `on` childrenIn xs) (tail $ LL.inits x)
              of
                Nothing -> over unCompletionTree (M.insert x mempty) (fromList xs)
                Just parent
                  -> case first (x :) $ partition (parent `LL.isPrefixOf`) xs of
                       ([_], rest)
                         -> over unCompletionTree (M.insert parent mempty) $ fromList rest
                       (hasParent, rest)
                         -> over
                              unCompletionTree
                              (M.insert
                                 parent
                                 (fromList $ map (fromJust . LL.stripPrefix parent) hasParent))
                              $ fromList rest
            where
                childrenIn list parent
                  = length $ filter (parent `LL.isPrefixOf`) list
   |
88 |       where childrenIn list parent = length $ filter (parent `LL.isPrefixOf`) list
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Yi/CompletionTree.hs:(181,5)-(183,97): error:
    • Non type-variable argument
        in the constraint: ListLike a1 (GHC.Exts.Item a1)
      (Use FlexibleContexts to permit this)
    • When checking the inferred type
        toList' :: forall a.
                   ListLike a (GHC.Exts.Item a) =>
                   CompletionTree a -> [a]
      In an equation for ‘toList’:
          toList ct
            | mempty == ct = []
            | otherwise = toList' ct
            where
                toList' (CompletionTree ct')
                  | M.null ct' = [mempty]
                  | otherwise
                  = concat
                      $ M.elems
                          $ M.mapWithKey (\ k v -> map (k `LL.append`) $ toList' v) ct'
    |
181 |     toList' (CompletionTree ct')
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

bash-4.3$