- May 27th, 2018:
data F = F { a, b, c :: String }
data Stamped a = { time :: Day, stamped :: a }
f :: Stamped F -> String
output of f x is "time a b c" for the respective values of time, a, b, c
Is there some monadic / applicative elegant definition that does this? - Nickolay Kudasov @crazy_fizruk
f = intercalate “ “ . sequence [ show.time, a.stamped, b.stamped, c.stamped ] - Nickolay Kudasov @crazy_fizruk
f = intercalate " " <$> http://pure.show .time <> (sequence [a, b, c]).stamped
A bit trickier, but shorter and uses stamped once. - April 13th, 2018: given f :: [a] -> b -> [c]
where c is a derived from g :: a -> b -> c
You have [a] and [b]
Write a function h :: [a] -> [b] -> [c] from f
Incorporates strong typing over predicate logic programming, and, conversely, incorporates predicate logic programming into strongly typed functional languages. The style of predicate logic is from Prolog; the strongly typed functional language is Haskell.
Monday, February 18, 2019
April/May 2019 1HaskellADay 1Liners
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment