#4385: Type-level natural numbers
----------------------------------------+-----------------------------------
Reporter: diatchki | Owner: diatchki
Type: feature request | Status: new
Priority: normal | Milestone: 7.4.1
Component: Compiler (Type checker) | Version:
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
----------------------------------------+-----------------------------------
Comment(by sjoerd_visscher):
Replying to [comment:38 dankna]:
> So that would work, except as far as I can tell, the obvious way to
define type-level integers in terms of type-level naturals isn't possible.
Have you tried defining type-level integer in terms of 2 type-level
naturals, the value being the difference between the 2 naturals:
{{{
data IntType :: Nat -> Nat -> *
type family Minus a b
type instance Minus (IntType a b) (IntType c d) = IntType (a + d) (b + c)
}}}
The type for f.e. -2 would then be `forall n. IntType n (n + 2)`.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4385#comment:42>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs