functional programming - Example of a matrix as Applicative functor -
i asked similar question not clear enough, decided rephrase it.
i know matrix applicative functor not monad. wondering if there simple , practical example of <*> matrices.
a possible applicative instance matrices make analogous ziplist. f matrix of functions, , x matrix of values, f <*> x applies each function in f pointwise each value in x. result truncated in each dimension fit shortest matrix. pure f gives infinite matrix f @ each point. example example, pointwise matrix multiplication (*) <$> <*> b.
in stead of truncation , working infinity, fix shape of matrix using phantom type parameter used in accelerate. of course, declare monad instance fixed size ziplists.
Comments
Post a Comment