Cannot use ghci type output signature to return Sing (d :: Symbol) function

I am trying to restore Symbolused in value type:

{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Temp where

import GHC.TypeLits

data Temp (d :: Symbol) (a :: *) where 
  T :: a -> Temp d a

{-
description :: SingI Symbol d => Temp d a -> Sing Symbol d
-}
description (_ :: Temp d a) = (sing :: Sing d)

This loads the penalty into ghci(version 7.6.1):

% ghci
GHCi, version 7.6.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :l Temp
[1 of 1] Compiling Temp             ( Temp.hs, interpreted )
Ok, modules loaded: Temp.
*Temp> :t description
description :: SingI Symbol d => Temp d a -> Sing Symbol d

However, if I try to use the type entered ghciin the module itself (uncommenting the line in Temp.hs), I get the following error:

Temp.hs:14:16:
    `SingI' is applied to too many type arguments
    In the type signature for `description':
      description :: SingI Symbol d => Temp d a -> Sing Symbol d

This makes sense to me, since it Singalso SingIseems to use one parameter in the documentation .

What is the correct type signature for description?

+5
source share
1 answer

Ok, missed a few monkeys:

description :: SingI d => Temp d a -> Sing d

It seems like some kind of funky rewriting is happening, but right now it's pretty good.

+2
source

All Articles