aboutsummaryrefslogtreecommitdiff
path: root/data/functor.scm
blob: 4e4722f6bbb79b045ba1283d8bf1d5129ce65251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(define-module (data functor)
  #:use-module (oop goops)
  #:use-module (srfi srfi-1)
  #:use-module (ice-9 curried-definitions)
  #:export (fmap <$> cmap))

;;; We don't overwrite the default map since that creates way to many
;;; namespace problems.

(define-generic fmap)
(define <$> fmap)

;;; Default fallback for fmap is regular (srfi-1) map.
(define-method (fmap f . lists)
  (apply map f lists))

;; Curried map
(define ((cmap f) item)
  (fmap f item))