Last active
February 20, 2020 08:13
-
-
Save guillaumewuip/5e8cdc20f512a6d9f1f4d659546f41ef to your computer and use it in GitHub Desktop.
How to model your entities - 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createFold } from ‘@iadvize-oss/foldable-helpers’; | |
// fold :: (TextMessage -> R) -> (ImageMessage -> R) -> (AudioMessage -> R) -> Message -> R | |
// “feeding” the fold-creator with our previously created type guards | |
const fold = createFold(isText, isImage, isAudio); | |
// or, passing function with an object to give them names | |
import { createFoldObject } from ‘@iadvize-oss/foldable-helpers’; | |
// fold :: ({ | |
// isText: TextMessage -> R, | |
// isImage: ImageMessage -> R, | |
// isAudio: AudioMessage -> R | |
// }) -> Message -> R | |
const fold = createFoldObject({ isText, isImage, isAudio }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment