- 562 名前:デフォルトの名無しさん mailto:sage [2020/11/02(月) 00:43:34.64 ID:TnMF05Pn.net]
- 質問です
このサイトでNum instanceをDerivingする話が出てました https://qiita.com/HirotoShioi/items/8a6107434337b30ce457 実際このページの次のコードはうちの環境でも通ります Haskell Online Compiler [ghc-8.4.4] Copyright (c) The University of Glasgow {-# LANGUAGE GeneralizedNewtypeDeriving #-} newtype Quantity = Quantity Int deriving (Eq, Ord, Num, Show) a = Quantity 2 b = Quantity 6 totalQuantity :: Quantity totalQuantity = a + b -- Quantity 8 しかし次は通りません 通す事はできますか? import Text.ParserCombinators.Parsec import Text.Parsec (Parsec) newtype ParserInt = PI (Parser Int) deriving (Num)
|

|