[Haskell-cafe] Existential quantification of config data types

Charlie Durham cpdurham at gmail.com
Mon Apr 18 18:45:51 UTC 2016


Hi,

I'm running into a weird problem i've never had before.

I want to define a datatype like:

data Network = forall a. Layer a => Network [a]

for which I have things that implement Layer, like

data TypicalLayer = ...

instance Layer TypicalLayer where ...

with this, I want to be able to load a Network from a config file where
Network can consist of different data types all implementing Layer.

Is there a nice way to do this without making a data type that combines all
of my layer types, something like:

data LayerType = TypicalLayerType TypicalLayer | AnotherLayerType
AnotherLayer ...

deriving (Show,Read)

Thanks for the help!

Charlie Durham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160418/1d911872/attachment.html>


More information about the Haskell-Cafe mailing list