Skip to content

Instantly share code, notes, and snippets.

@ClarkeRemy
Created April 1, 2025 14:36
Show Gist options
  • Save ClarkeRemy/204280929ecb22ffd842805d2216a2b5 to your computer and use it in GitHub Desktop.
Save ClarkeRemy/204280929ecb22ffd842805d2216a2b5 to your computer and use it in GitHub Desktop.
Bad Typeclass Prolog
fAtoB_optionA_optionB(_, none, none).
fAtoB_optionA_optionB(F, option(A), option(B)) :- C =.. [F,A,B], C.
functor_map(option, fAtoB_optionA_optionB).
fmapAtoB_fA_fB(Func, F_A, F_B) :-
( nonvar(F_A) -> F_A =.. [F| _]
; nonvar(F_B) -> F_B =.. [F| _]
),
functor_map(F, Map),
C =.. [Map, Func, F_A, F_B],
C.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment