Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ctford
Created November 4, 2017 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctford/43ba6978712fd30c01ee61da13b3aa0d to your computer and use it in GitHub Desktop.
Save ctford/43ba6978712fd30c01ee61da13b3aa0d to your computer and use it in GitHub Desktop.
Fuse a chain of functions
module Data.Chain
%default total
data Chain : Type -> Type -> Type
where
Link : (a -> b) -> Chain a b
Section : (a -> b) -> Chain b c -> Chain a c
fuse : Chain a b -> a -> b
fuse (Link f) x = f x
fuse (Section f g) x = fuse g $ f x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment