Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Two thoughts (wild guesses?) it looks as if it is failing to produce the right type signature in the <code>Just obj</code> clause and/or from <code>readObj name</code>, and it might be interesting to try something like this:</p> <pre><code>loader' :: [(String, ObjType)] -&gt; String -&gt; (ObjType, String -&gt; ObjType) loader' objs name = case findObj objs name of Nothing → (new_obj, loader' new_objs) where new_objs = [(name, new_obj)] ++ objs new_obj = readObj name Just obj → (obj, loader' objs) loader = loader' [] </code></pre> <p>I'm not saying that that will fix it (but I suppose that it might); rather, I'm saying that it may transform the problem into one that makes more sense, or otherwise shed light on the situation.</p> <p>Edit:</p> <p>Applying Tom Lokhorst's suggestion of naming the cache type leads us to this:</p> <pre><code>type Cache = [(String, ObjType)] loader' :: Cache -&gt; String -&gt; (ObjType, ????) loader' objs name = case findObj objs name of Nothing → (new_obj, loader' new_objs) where new_objs = [(name, new_obj)] ++ objs new_obj = readObj name Just obj → (obj, loader' objs) loader = loader' [] </code></pre> <p>which makes it obvious what the problem is. The type of the second result of loader' is a function that takes a string an produces a pair consisting of an ObjType and a function that takes a string an produces a pair consisting of an ObjType and a function that takes a string an produces a pair consisting of an ObjType and a function that takes a string an produces a pair consisting of an ObjType and ... you get the picture.</p> <p>If you rewrite it like this:</p> <pre><code>type Cache = [(String, ObjType)] loader' :: Cache -&gt; String -&gt; (ObjType, Cache) loader' objs name = case findObj objs name of Nothing → (new_obj, new_objs) where new_objs = [(name, new_obj)] ++ objs new_obj = readObj name Just obj → (obj, objs) </code></pre> <p>it should compile but you'll have to change how you use it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload