Skip to content

Commit

Permalink
Add combinators
Browse files Browse the repository at this point in the history
  • Loading branch information
vvscode committed May 8, 2018
1 parent b816b9d commit 15b8a17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ChurchNum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module ChurchNum (
) where

import Base
import Combinators

-- zero :: p2 -> t3 -> t3
zero = Base.flip constant
Expand All @@ -21,8 +22,9 @@ zero = Base.flip constant
one = apply

-- two :: (t -> t) -> t -> t
-- @help: can't figure out point free version
two x y = x $ x y
-- @help: can't figure out point free version (cause s-combinator is not)
-- two x y = x $ x y
two = s Base.compose identity

-- inc :: Num a => a -> a
inc = (+1)
Expand Down
5 changes: 5 additions & 0 deletions src/Combinators.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Combinators where

s f g x = f x (g x) -- S-combinator
identity x = x -- I-combinator
constant x y = y -- K -combinator

0 comments on commit 15b8a17

Please sign in to comment.