Skip to content

Instantly share code, notes, and snippets.

@JordanMartinez
Created July 25, 2020 04:11
Show Gist options
  • Select an option

  • Save JordanMartinez/df17eceb4442f79c7c07b8607286e98e to your computer and use it in GitHub Desktop.

Select an option

Save JordanMartinez/df17eceb4442f79c7c07b8607286e98e to your computer and use it in GitHub Desktop.
MemoizeFibonacci issue
module Main where
import Prelude
import Data.Function.Memoize (memoize)
import Data.Interpolate (i)
import Debug.Trace (spy)
import Effect (Effect)
import Effect.Class.Console (log)
main :: Effect Unit
main = do
log $ i "fibBroken4 result: " $ fibBroken4 7
fibBroken4 :: Int -> Int
fibBroken4 0 = spy "fibBroken4 0" 0
fibBroken4 1 = spy "fibBroken4 1" 1
fibBroken4 n =
spy ("fibBroken4 " <> show n)
$ fibPointFreeMemoize (n - 2)
+ fibPointFreeMemoize (n - 1)
{-
The value of fibBroken4 is undefined here, so this reference is not allowed.
while checking that expression fibBroken4
has type t0 -> t1
while applying a function memoize
of type Tabulate t0 => (t0 -> t1) -> t0 -> t1
to argument fibBroken4
in binding group fibBroken4, fibPointFreeMemoize
where t1 is an unknown type
t0 is an unknown type
-}
fibPointFreeMemoize :: Int -> Int
fibPointFreeMemoize = memoize fibBroken4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment