Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,865
    • Issues 4,865
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 461
    • Merge requests 461
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19361
Closed
Open
Created Feb 13, 2021 by Jaro Reinders@NoughtmareDeveloper

Linear Types confusing error message

Summary

When implementing a partition function I tried adding a polymorphic linear type annotation, which gave a very strange error message: "Couldn't match type ‘'Many’ with ‘'Many".

Steps to reproduce

Here is my code:

{-# LANGUAGE LinearTypes #-}

part :: (a -> Bool) -> [a] %p -> ([a], [a])
part _ [] = ([],[])
part f (x : xs)
  | f x = (x : l, r)
  | otherwise = (l, x : r)
  where
    ~(l, r) = part f xs

This gives the error message:

QS.hs:22:13: error:
    • Couldn't match type ‘'Many’ with ‘'Many’
        arising from multiplicity of ‘xs’
      ‘p’ is a rigid type variable bound by
        the type signature for:
          part :: forall a. (a -> Bool) -> [a] -> ([a], [a])
        at QS.hs:20:1-43
    • In the pattern: x : xs
      In an equation for ‘part’:
          part f (x : xs)
            | f x = (x : l, r)
            | otherwise = (l, x : r)
            where
                ~(l, r) = part f xs
    • Relevant bindings include
        part :: (a -> Bool) -> [a] -> ([a], [a]) (bound at QS.hs:21:1)    

Expected behavior

Compile without errors or with a more sensible error. Why can't Many be matched with Many?

Environment

  • GHC version used: 9.0.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking