never executed always true always false
    1 module HelVM.HelMA.Automata.LazyK.InputEncoder where
    2 
    3 import           HelVM.HelMA.Automata.LazyK.Constants
    4 import           HelVM.HelMA.Automata.LazyK.Lambda
    5 
    6 import qualified Data.ByteString.Lazy                 as LBS
    7 
    8 -- | Constructors
    9 readInput :: LBS.ByteString -> Lambda
   10 readInput = encodeInput . fmap fromIntegral . LBS.unpack
   11 
   12 encodeInput :: [Natural] -> Lambda
   13 encodeInput = foldr (cons . church) end
   14 
   15 -- | Other
   16 end :: Lambda
   17 end = cons (church 256) false
   18 
   19 cons :: Lambda -> Lambda -> Lambda
   20 cons a b = app3 S (app3SI (appK a)) (appK b)
   21 
   22 church :: Natural -> Lambda
   23 church 0   = false
   24 church 1   = I
   25 church 4   = appSelfApp $ church 2
   26 church 8   = church 3 `App` church 2
   27 church 9   = church 2 `App` church 3
   28 church 16  = church 2 `App` church 4
   29 church 25  = church 2 `App` church 5
   30 church 27  = appSelfApp $ church 3
   31 church 36  = church 2 `App` church 6
   32 church 64  = church 3 `App` church 4
   33 church 81  = church 4 `App` church 3
   34 church 100 = church 2 `App` church 10
   35 church 121 = church 2 `App` church 11
   36 church 125 = church 3 `App` church 5
   37 church 256 = appSelfApp $ church 4
   38 church n   = succChurch $ n - 1
   39 
   40 succChurch :: Natural -> Lambda
   41 succChurch = successor . church
   42 
   43 successor :: Lambda -> Lambda
   44 successor = app3 S bCombinator