Reputation: 34099
I have following data type definition:
newtype Combine a b =
Combine { unCombine :: a -> b }
and then I can defined as follow:
Prelude> let f = Combine $ \n -> Sum (n + 1)
My question is, how to use f
?
Upvotes: 3
Views: 68
Reputation: 233377
Prelude Data.Monoid> unCombine f 1
Sum {getSum = 2}
Prelude Data.Monoid> unCombine f 42
Sum {getSum = 43}
Upvotes: 7