[GHC] #14922: Add inductively-defined Nat to base

GHC ghc-devs at haskell.org
Wed Mar 14 20:46:15 UTC 2018


#14922: Add inductively-defined Nat to base
-------------------------------------+-------------------------------------
           Reporter:  chessai        |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:                 |           Version:  8.2.2
  libraries/base                     |
           Keywords:  base           |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The proposed addition is simple, add the following to base:

 {{{#!hs
 data Nat = Zero | Succ Nat
 }}}

 I will list the pros/cons I see below.

 Pros:
 - Commonly defined throughout many packages, e.g. vinyl
 - The inductive definition of 'Nat' is useful for correctness
   (e.g. {{{#!hs safeHead :: Vec a (S n) -> a; safeHead (Cons a as) = a}}})

 Cons:
 - '-XDependentHaskell' will most likely obviate any benefit brought about
 by type families involving Nat
 - Looking at base, I'm not sure where this would go. Having it in its own
 module seems a tad strange.

 I am open to criticism concerning the usefulness of the idea or if anyone
 sees a Pro(s)/Con(s) that I am missing.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14922>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list