[GHC] #14718: Add Boolean type families to 'base' package

GHC ghc-devs at haskell.org
Thu Jan 25 11:41:15 UTC 2018


#14718: Add Boolean type families to 'base' package
-------------------------------------+-------------------------------------
           Reporter:  chshersh       |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Core           |           Version:  8.5
  Libraries                          |
           Keywords:  base, type     |  Operating System:  Unknown/Multiple
  families, Bool                     |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Sometimes you want type families to perform type level computation with
 booleans.
 Specifically:
 {{{#!hs
 type family If (p :: Bool) (ifTrue :: k) (ifFalse :: k) :: k where ...
 type family (a :: Bool) && (b :: Bool) :: Bool where ...
 type family (a :: Bool) || (b :: Bool) :: Bool where ...
 type family Not (a :: Bool) :: Bool where
 }}}

 Similar to existing module
 [https://hackage.haskell.org/package/base-4.10.1.0/docs/Data-Bool.html
 Data.Bool] in `base` package for boolean expressions.

 There's not a single package with such type families for type-level
 boolean computations. Even if it exists it probably would very small. And
 as a library author you probably don't wan extra dependencies for your
 package because cost of adding new dependency for your project is much
 bigger than cost of adding module to existing dependencies (if it's
 possible of course).

 It seems to me that such operations are kinda basic. And they just promote
 behavior of already existed expression-level functions to type level. And
 we already have type families for `Integer`, `Natural` and `String` (aka
 `Symbol`) and several type families returning `Bool` (`==`, `<=?`) in
 `base`. So I propose to add couple useful utilities to operate with `Bool`
 explicitly.

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


More information about the ghc-tickets mailing list