2012-09-24 11 views
5

sto cercando di recuperare il Symbol utilizzato nel tipo di un valore:Impossibile utilizzare il tipo di firma ghci-desunti per funzione che restituisce Canta (d :: Symbol)

{-# 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) 

Questo carica bene in ghci (versione 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 

Tuttavia, se si tenta di utilizzare il tipo inferita da ghci nel modulo stesso (commentando la linea in Temp.hs), ottengo il seguente errore:

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 

Il che ha senso per me, dal Sing and SingI seem to take a single parameter in the documentation.

Qual è la firma del tipo corretto per description?

+2

Sembra un errore nella stampante carina; sembra che non dovrebbe essere una bella stampa di valori dedotti di argomenti di tipo implicito se non puoi dare esplicitamente tali argomenti gentili! –

+1

Ho osservato lo stesso display buggy con 'Nat'. Avevo pensato che stessero cercando di stampare una specie di firma in qualche modo, ma mostrare in maniera errata un argomento implicito ha più senso ... –

risposta

2

Ok, ce l'ha attraverso alcuni monkeying su:

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

Sembra che ci sia qualche riscrittura funky in corso, ma abbastanza buono per ora.

Problemi correlati