Haskellは数学ではない 0758デフォルトの名無しさん2021/02/26(金) 10:03:43.32ID:W2dsUZYE モノイドでも集合論でも、公理が多過ぎて公理が偽になるなら 公理を減らせばいいじゃん 0759デフォルトの名無しさん2021/02/26(金) 10:24:37.14ID:nFSf/y++>>754 まず単位元の定義から、esが[a]の単位元であるなら、任意のxsに対して f es xs == xs f xs es == xs を満たす、というところはいいよね(ゆえにesは、任意のxsより要素数が大きくなければいけない)
カリーハワード同型対応とプログラムとの関係性ですか? それとも、カリーハワード同型対応がプログラムの何に役立つのかですか? それとも、call by name と call by need との違いですか。 それとも、その論文の内容ですか。 (その場合、PDFの5ページ目まで、つまり横線の式が登場する部分まではちゃんと理解できていると思っていいのですか?)
main :: IO () main = do let a = L.transpose [[1, 2], [3, 4]] let b = transpose (1, 2) putStrLn $ show a ++ " / " ++ show b 0796デフォルトの名無しさん2021/04/06(火) 12:32:00.21>>795 値コンストラクタ名に被りがあった場合、それができないようなのです import モジュールの側の同名値コンストラクタを、qualifiedして修飾しましたので今書いてるモジュールの方を修飾なしで書いたのですが それはAmbiguousだと怒られます 0797デフォルトの名無しさん2021/04/06(火) 20:13:47.61ID:sYlI8eNJ ホントだ 怒られた
import qualified Data.Bool as B
data MyBool = True | False
instance Show MyBool where show Main.True = "MyTrue" show Main.False = "MyFalse"
instance Show MyExitCode where show ExitSuccess = "MyExitSuccess" show ( ExitFailure x ) = "MyExitFailure " ++ ( show x )
main = do print ExitSuccess print S.ExitSuccess print $ ExitFailure 12 print $ S.ExitFailure 12 0803デフォルトの名無しさん2021/04/06(火) 22:52:08.72ID:vUIEomdt>>796 エラーメッセージは省略せずに書いてほしい 0804デフォルトの名無しさん2021/04/07(水) 15:24:37.74 module BinaryRepresentation.Word8 ( BiRep8( Rep) ) where import Data.Word( Word8)
newtype BiRep8 = Rep Word8
instance Show BiRep8 where show a = show' 8 a "" where show' 0 _ s = s show' count (Rep w8) s = let (q,r) = w8 `quotRem` 2 in show' (count-1) (Rep q) (r `shows` s) ---------↑binary_representation8.hs----------------------------- 0805デフォルトの名無しさん2021/04/07(水) 15:24:59.63 module BinaryRepresentation.IPAddress( IPv4Address, BiRepIPv4Address( Rep), makeIPv4 ) where import Data.Word( Word8) import Data.List( intersperse) import BinaryRepresentation.Word8( BiRep8( Rep)) import qualified BinaryRepresentation.Word8 as Bi8
newtype IPv4Address = A (Word8, Word8, Word8, Word8)
ipshow::Show s=> (Word8->s) -> [Word8] -> String ipshow f list = concat . intersperse "." $ (show . f) <$> list
instance Show IPv4Address where show (A (_1,_2,_3,_4)) = ipshow id [_1,_2,_3,_4]
newtype BiRepIPv4Address = Rep IPv4Address
instance Show BiRepIPv4Address where show (Rep (A (_1,_2,_3,_4))) = ipshow Bi8.Rep [_1,_2,_3,_4]
binary_representation_ipv4.hs:24:11: error: Ambiguous occurrence ‘Rep’ It could refer to either ‘BinaryRepresentation.Word8.Rep’, imported from ‘BinaryRepresentation.Word8’ at binary_representation_ipv4.hs:8:36-47 or ‘BinaryRepresentation.IPAddress.Rep’, defined at binary_representation_ipv4.hs:21:28 | 24 | show (Rep (A (_1,_2,_3,_4))) | ^^^ ------------------------------------------------ 意図:Word8 値を01表記で表現するモジュールを作り、それを用いてIPv4アドレスを01表記で表現する 問題:binary_representation_ipv4.hs のRepが、binary_representation8.hs のRepと被りAmbiguousである 判明しているワークアラウンド:24行目のRep を BinaryRepresentation.IPAddress.Rep という糞ダサコードへ書き換える 望む事:修飾せずに済ますか、短い修飾で済ませたい 0807デフォルトの名無しさん2021/04/07(水) 15:51:36.65ID:6KWn3Zlg import BinaryRepresentation.Word8( BiRep8( Rep)) ↑これ何?消せば? 0808デフォルトの名無しさん2021/04/07(水) 18:16:48.26 はわわ。。。通りました 下手にimport書いたせいで通らなくなるとかあるんですね 蛇足importと名付けて教訓にします。ありがとうございました 0809デフォルトの名無しさん2021/04/07(水) 23:07:15.55ID:PA0bBjRm>>808 勘でコード書いてるのかよw 0810デフォルトの名無しさん2021/04/13(火) 20:07:55.95ID:WnmkLZut>>808 > 下手にimport書いたせいで通らなくなるとかあるんですね
ちょ・・・・ 0811デフォルトの名無しさん2021/04/16(金) 21:11:12.10ID:trr1lKH1 "http2" library v3.0.0 in Haskell has been released 0812デフォルトの名無しさん2021/04/16(金) 21:38:11.49ID:gUR6Epkt>>794 型駆動開発(TDD)はidris作者が本出してるけどそれのことかいな?
Cに適応しすぎているという認識は本当に正しいのか? ここでも楽観と悲観が対立する 0828デフォルトの名無しさん2021/05/21(金) 15:54:58.85 長く時間がかかるプログラムを走らせた時、タスクマネージャーを眺めると、少数のコアに高負荷、残り全コアに低負荷がかかってるみたいなのですが 実行時に使用コア数は指定していないことから推測すると、ガベコレは全コアで稼働するってことでしょうか? 0829デフォルトの名無しさん2021/05/22(土) 13:34:14.84ID:hkOb3/u2 Haskellのは単にシングルスレッドで回収してるだけだぞ 0830デフォルトの名無しさん2021/05/22(土) 20:46:21.69 え、じゃあなんで全コア低負荷になったんだろ・・・ 数分毎に階段のようにRAM使用量が数GBずつ増えて行って 長い処理が終了する直前に全コアフル稼働になって、直後に処理終了になったから ガベコレが関与してると思ったんですがね 0831デフォルトの名無しさん2021/05/22(土) 21:35:55.30ID:aaz7cUPO サンクが溜まってって最後に遅延してそれらを評価したのでは というかパフォーマンスの話は変に予測立てたり先入観あったりするとろくなことないからもっと詳細にプロファイリングしたほうが 0832デフォルトの名無しさん2021/05/22(土) 21:58:08.22ID:Up5XEM4X ガベコレ以外に考えられる原因が2つぐらいあったら ガベコレが原因である確率は1/3ぐらいだから 2/3の方が勝ちそう 0833デフォルトの名無しさん2021/05/29(土) 14:13:39.92ID:SnGl3AHf win10でstackとかghcそのものは正常に入るんたけどパッケージのコンパイルが絡んでくるとどうも文字コードが原因でコケる LANG=asciiにすると挙動が変わってくるんだけど、何にしとくのが正解なんだろ 0834デフォルトの名無しさん2021/05/29(土) 16:46:49.24ID:1zrkc3qO 100万要素の配列の1要素を更新するために配列の再作成が必要? https://www.quora.com/Is-Haskell-as-fast-as-C++-If-not-why-not/answer/James-Hollis-19 > Haskell naturally operates on lists, but is rather awkward with arrays. Pure functions do not modify their input, so a pure function that changes one element of a million element array will copy 999,999 elements into a second array and return that. You can get around this with monads, but you end up writing imperative code in something that is less flexible than real imperative code.
<no location info>: error: Could not find module ‘Numeric.LinearAlgebra’ Perhaps you haven't installed the "dyn" libraries for package ‘hmatrix-0.20.2’? Use -v to see a list of the files searched for.