2018-05-01から1ヶ月間の記事一覧
*> sample' (vectorOf 4 $ choose ('a','z')) ["jvnv","ylqf","aoud","bdha","lekn","ahoy","yzdp","nyso","zzlo","gjii","cyjg"] Ascii文字列とかUnicode文字列とか生成する機能があります。一度しっかりドキュメントを読んでおくとお釣りか来る感じ。 *> s…
インストールのログ Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\User> iex (new-object net.webclient).downloadstring('https://get.scoop.sh') PowerShell requires an execution policy of 'RemoteSigne…
CPSによる階乗計算 > :{ | fac 0 k = k 1 | fac n k = fac (n-1) $ \res -> k $ (*) n res | :} > fac 3 id 6 > fac 3 (+1) -- (1 * 2 * 3) + 1 7 手計算してみる。 fac 3 k = fac 2 $ \res -> k $ (*) 3 res = fac 1 $ \res1 -> (\res -> k $ (*) 3 res) $ …
通常のghciで開くとlibまたはexe側でghciが開く $ stack ghci テスト側で開きたい時はテストスイート名を明示的に指定する。 $ stack ghci :RFC5646-test
name: hoge tests: foo-test: main: Spec.hs source-dirs: test bar-doctest: main: test/doctests.hs と2つのテストスイートfoo-testとbar-doctestを定義する。 このときstack testでテストが実行されるが、両方とも実行される。 片方だけ実行したい場合は …
Regrex {min, max} for Attoparsec
なんらかのデータを取得する処理をして、あればそれを使い、なければ、別途データを取得する というロジックは、よくあるのではないでしょうか。 例えば、このような場合です。 import qualified Data.HashMap.Lazy as HML m = HML.fromList [("k1", "**"), …
Data.Functor.Contravariant covariant functor ~~> produce something contravariant functor ~~> consume something (>$) = contramap . const const :: a -> b -> a contramap :: Contravariant f => (a -> b) -> f b -> f a contrampa . const = x -> y …
haskell/lens.md at master · lotz84/haskell · GitHub haskell - How to write an instance of Control.Lens.AT - Stack Overflow Oleg's gists - Glassery
lambda > import Control.Lens lambda > :t iso iso :: (Functor f, Profunctor p) => (s1 -> a1) -> (b1 -> t1) -> p a2 (f b2) -> p s2 (f t2) lambda > let foo = iso (\((a,b),c)->(a,(b,c)) (\(a,(b,c))->((a,b),c))) lambda > let foo = iso (\((a,b),…
Preludeにあるheadは安全ではない lambda > import Control.Lens.Cons lambda > head [1,2,3] 1 lambda > head [] *** Exception: Prelude.head: empty list Safeパッケージがある。 lambda > import Safe lambda > headMay [1,2,3] Just 1 lambda > headMay…
Infinite loop on Attopersec