Skip to content
GitLab
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 5,246
    • Issues 5,246
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 564
    • Merge requests 564
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17208
Closed
Open
Issue created Sep 18, 2019 by Sebastian Graf@sgraf812Developer

Trivial exhaustiveness checking for view patterns and guards

As discussed in #15753 (closed), ee should have better exhaustiveness checking for view patterns and guards. For example, I would expect the following program not to generate any warnings:

{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
{-# LANGUAGE ViewPatterns #-}

module Lib where

safeLast :: [a] -> Maybe a
safeLast xs
  | []    <- reverse xs = Nothing
  | (x:_) <- reverse xs = Just x

safeLast2 :: [a] -> Maybe a
safeLast2 (reverse -> [])    = Nothing
safeLast2 (reverse -> (x:_)) = Just x

safeLast3 :: [a] -> Maybe a
safeLast3 xs
  | []    <- reverse xs = Nothing
safeLast3 xs'
  | (x:_) <- reverse xs' = Just x
Edited Oct 09, 2019 by Sebastian Graf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking