[過去ログ]
関数型プログラミング言語Haskell Part33 (1002レス)
関数型プログラミング言語Haskell Part33 http://mevius.5ch.net/test/read.cgi/tech/1581326256/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
550: デフォルトの名無しさん [sage] 2020/11/02(月) 00:43:34.64 ID:TnMF05Pn 質問です このサイトで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) http://mevius.5ch.net/test/read.cgi/tech/1581326256/550
551: デフォルトの名無しさん [sage] 2020/11/02(月) 00:43:43.72 ID:TnMF05Pn ---- エラーメッセージ Haskell Online Compiler [ghc-8.4.4] Copyright (c) The University of Glasgow Compiling your program... [1 of 1] Compiling Main ( prog.hs, prog.o ) prog.hs:6:47: error: • No instance for (Num (Parser Int)) arising from the 'deriving' clause of a data type declaration Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself • When deriving the instance for (Num ParserInt) | 6 | newtype ParserInt = PI (Parser Int) deriving (Num) | ^^^ http://mevius.5ch.net/test/read.cgi/tech/1581326256/551
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.059s