[GHC] #12921: initTc: unsolved constraints
GHC
ghc-devs at haskell.org
Mon Jul 10 21:06:15 UTC 2017
#12921: initTc: unsolved constraints
-------------------------------------+-------------------------------------
Reporter: jlp | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.2.1
Component: Compiler (Type | Version: 8.0.1
checker) |
Resolution: fixed | Keywords:
Operating System: MacOS X | Architecture: x86_64
| (amd64)
Type of failure: Compile-time | Test Case:
crash or panic | typecheck/should_fail/T12921
Blocked By: | Blocking:
Related Tickets: #13106 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by gnezdo):
I located a binary and after fixing up the code it's working. Thanks!
{{{
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Proxy
import GHC.TypeLits
-- | The floor of log_2(n).
type family Log2 n where
Log2 1 = 0
Log2 n = Log2 (Div2 n) + 1
-- | The floor of n/2.
type family Div2 n where
Div2 0 = 0
Div2 1 = 0
Div2 n = Div2 (n - 2) + 1
valueOf :: forall (n :: Nat) . (KnownNat n) => Integer
valueOf = natVal (Proxy :: Proxy n)
}}}
{{{
$ ./ghc-install/bin/ghci a.hs
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( a.hs, interpreted )
Ok, 1 module loaded.
*Main> :set -XDataKinds
*Main> :set -XTypeApplications
*Main> valueOf @(Log2 3)
1
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12921#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list