Refactoring
This commit is contained in:
parent
cb1c461049
commit
76b1b0ca24
@ -152,30 +152,27 @@ def make_eithered_image_metadata_pair(image: Either, metadata: Either) -> Either
|
||||
# a := Image
|
||||
# b := Metadata
|
||||
# c := ImageMetadataPair
|
||||
# m := Either monad
|
||||
|
||||
# fmt: off
|
||||
# 1)
|
||||
# return (
|
||||
# pair: Either = (
|
||||
# Right(make_image_metadata_pair) # m (a -> b -> c)
|
||||
# .amap(image) # m (a -> b -> c) $ m a = m (b -> c)
|
||||
# .amap(metadata) # m (b -> c) $ m b = m c
|
||||
# .either(
|
||||
# left(context),
|
||||
# right(identity),
|
||||
# )
|
||||
# .amap(image) # m (a -> b -> c) <*> m a = m (b -> c)
|
||||
# .amap(metadata) # m (b -> c) <*> m b = m c
|
||||
# )
|
||||
|
||||
# 2)
|
||||
# return (
|
||||
# pair: Either = (
|
||||
# image.bind(right(make_image_metadata_pair)) # m a >>= m (a -> b -> c) = m (b -> c)
|
||||
# .amap(metadata) # m (b -> c) <*> m b = m c
|
||||
# .either(
|
||||
# left(context),
|
||||
# right(identity),
|
||||
# )
|
||||
# )
|
||||
# fmt: on
|
||||
|
||||
# Syntactic sugar variant:
|
||||
return Either.apply(make_image_metadata_pair).to_arguments(image, metadata).either(left(context), right(identity))
|
||||
# Syntactic sugar variant with details hidden
|
||||
pair: Either = Either.apply(make_image_metadata_pair).to_arguments(image, metadata)
|
||||
|
||||
return pair.either(left(context), right(identity))
|
||||
|
||||
|
||||
@curry(2)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user