関数型プログラミング言語Haskell Part15
■ このスレッドは過去ログ倉庫に格納されています
0897デフォルトの名無しさん
2011/10/04(火) 20:44:51.24でも、ghci などで実行するとちゃんと値が返る
なので、手作業簡約の方が100%間違っているのは分かるが、どこがおかしい?
以下の定義のもとで、
import Control.Arrow
import qualified Control.Category as C
newtype SF a b = SF {runSF :: [a] -> [b]}
instance C.Category SF where
id = SF (map id)
SF g . SF f = SF (g . f)
instance Arrow SF where
arr f = SF (map f)
first (SF f) = SF (unzip >>> first f >>> uncurry zip)
nstance ArrowChoice SF where
left (SF f) = SF (\xs -> combine xs (f [y | Left y <- xs]))
where combine (Left _:xs) (y:ys) = Left y : combine xs ys
combine (Right x:xs) ys = Right x : combine xs ys
combine [] _ = []
h f = C.id ||| (f >>> h f)
次の式の簡約の様子が知りたい
runSF (h (arr undefined)) [Left 1]
==> [1]
■ このスレッドは過去ログ倉庫に格納されています