Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,251
    • Issues 4,251
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 394
    • Merge Requests 394
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #12048

Closed
Open
Opened May 12, 2016 by Icelandjack@IcelandjackReporter

Allow CustomTypeErrors in type synonyms (+ evaluate nested type family?)

I didn't find a ticket with this, but with wiki:Proposal/CustomTypeErrors you can't define a type synonym without it erroring:

-- error: …
--     • onetwothree
--     • In the type synonym declaration for ‘ERROR’
-- Compilation failed.
type ERROR = TypeError (Text "onetwothree")

but I often want to factor out error messages, they are clunky to write at the type level and I often want to reuse message in many different type families, especially when they can be determined by a type family. Here's a hypothetical example:

type family
  Whoami (ty :: Type) :: Symbol where
  Whoami Int   = "a number"
  Whoami Float = "a number"
  Whoami [_]   = "a list of things"
  Whoami _     = "something else"

I would like to write

type Error ty = 
  TypeError (Text "Expected a <...> but got ":<>: Text (Whoami ty))

Even when ‘inlined’, it displays Expected a GRUE but got 'Text (Whoami Int) and not • Expected a GRUE but got a number.:

a :: TypeError (Text "Expected a GRUE but got ":<>: Text (Whoami Int))
a = 'a'
Edited Mar 10, 2019 by Icelandjack
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#12048