I have the following custom data types:
data FirstPair' a b = FirstPair a b deriving (Show, Ord, Eq)
type FirstPair a = FirstPair' a a
data SecondPair' a b = SecondPair a b deriving (Show, Ord, Eq)
type SecondPair a = SecondPair' a a
I'm trying to create a GADT structure for my function:
data Generator a where
Success :: FirstPair a -> Generator (SecondPair a)
Fail :: FirstPair a -> Generator Bool
myFunction :: Generator a -> a
myFunction (Success fp) = SecondPair "21" "24"
myFunction (Fail fp) = False
The role of 'Generator' type is to enable me to force 'myFunction' to return an instance of 'SecondPair' if 'Success' is passed to it, and 'False' if 'Fail' is passed to it.
However, I'm getting this error:
"Could not deduce: a1 ~ [Char] from the context: a ~ SecondPair' a1 a1 bound by a pattern with constructor: Success :: forall a. FirstPair a -> Generator (SecondPair a)"
What am I doing wrong here?
ContextaPair'
, but you don't mention that. Can you post your actual code? – crockeea[Char]
values in your code. – chepner