代码 {-# LANGUAGE ScopedTypeVariables, TypeApplications #-}
-- I know this particular example is silly.
-- But that's not the point here.
g :: forall a . RealFloat a => Bool
g = True
main :: IO()
我想知道具体为什么地图不在以下工作: {-# Language RankNTypes #-}
module Demo where
import Numeric.AD
newtype Fun = Fun (forall a. Num a => [a] -> a)
test1 :: Fun
test1 = Fun $ \[u, v] -> (v - (u * u * u))
test
我玩弄单身的专业化: {-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
module Data.Test where
data SingBool (b :: Bool) where
STrue :: SingBool 'True
SFalse ::
随着GHC 8.0.2版下面的程序: import Debug.Trace
f=trace("f was called")$(+1)
main = do
print $ f 1
print $ f 2
输出: f was called
2
3
它是预期的行为?如果是,为什么?我预计字符串f was called要打印两次,一次在2之前,一次在3之前打印一次。