haskell-te: 3dc74b9c2ced665f0f649b13d538c659eaf3a03e
1: From: Chris Warburton
2: Date: Fri, 28 Jul 2017 12:44:08 +0100
3: Subject: Re: No variables available for parameterised types
4: Message-Id: <d7b518eda6e0cc84-f9b033d833db8cd0-artemis@nixos>
5: References: <d7b518eda6e0cc84-0-artemis@nixos>
6: In-Reply-To: <d7b518eda6e0cc84-0-artemis@nixos>
7:
8: Looking into this a bit more, I think the issue is that functions have
9: no Ord instance; since getArbGen checks for Ord and for Arbitrary, it's
10: not returning a generator.
11:
12: There are a few approaches we could take:
13:
14: - We could declare an `Ord` instance for functions.
15: - Since the Ord instances are what actually determine equality in
16: quickspec, we would have to do it "properly" or else risk breaking
17: the output
18: - There's no general way in Haskell to compare functions; they're
19: black boxes, so this seems like a no go
20: - We could use some intermediate datatype, such as lookup tables, which
21: we can easily make an Ord instance for (e.g. convert to an assoc
22: list, sort and compare lexicographically)
23: - This requires some sort of conversion layer, since the functions in
24: our signature are expecting normal functions (would be nice if ->
25: were more polymorphic/overloadable in Haskell!)
26: - Too invasive, probably requires too much work to integrate (there
27: are off-the-shelf datatypes we can use, but it's the
28: wrapping/unwrapping which would be a pain)
29: - We could see if the Ord instance is still needed
30: - It looks like it's needed for using the `fun0`, `fun1`, etc.
31: functions, but not the `gvars` functions.
32: - Even in the case of `funN`, only the last type needs to be Ord,
33: e.g. it's fine to have `map :: (a -> b) -> [a] -> [b]`, as long as
34: `[b]` is an instance of Ord; `[a]` and `(a -> b)` don't have to be.
35:
36: I'll try dumping the Ord constraint in RuntimeArbitrary's getArbGen, to
37: see if that will work.
Generated by git2html.