https://github.com/Helium4Haskell/lvm
Raw File
Tip revision: a516e95b66e989f1364567e9b4f3292266659d08 authored by Hage, J. (J) on 24 August 2019, 08:00:47 UTC
Getting rid of pesky compile time warnings
Tip revision: a516e95
length.core
----------------------------------------------------------------
-- Daan Leijen (c) 2001
--
-- $Revision$
-- $Author$
-- $Date$
----------------------------------------------------------------
module Length where

instruction primAddInt "addint" :: Int -> Int -> Int
instruction primLeInt  "leint"  :: Int -> Int -> Bool

data List a = Nil
            | Cons a (List a)

data Bool   = False
            | True


addInt x y = case x of x -> case y of y -> primAddInt x y
leInt x y  = case x of x -> case y of y -> primLeInt x y

length xs
  = let len n xs  = case xs of
                      Nil -> n
                      Cons x xx -> case addInt n 1 of
                                    m -> len m xx
    in len 0 xs

fromTo i n
  = case leInt i n of
      False -> Nil
      True  -> Cons i (fromTo (addInt i 1) n)

main
  = length (fromTo 1 100000)
back to top