Tying the knot in cyclic records

127 Views Asked by At

What is the best way to rewrite the following so it compiles? Both data-type depends on each other.

{-# LANGUAGE OverloadedStrings, DuplicateRecordFields #-}   
data Syn = S { inputs :: [Neu] }
data Neu = N { weigth :: Double, inputs :: [ Syn ] }
1

There are 1 best solutions below

0
On BEST ANSWER

Your code compiles fine (I took the liberty of giving it a module name), there are not errors:

% ghc -c so.hs
% cat so.hs
{-# LANGUAGE OverloadedStrings, DuplicateRecordFields #-}
module So where

data Syn = S { inputs :: [Neu] }
data Neu = N { weigth :: Double, inputs :: [ Syn ] }

% ls -l so.o
-rw-r--r--  1 tommd  wheel  4888 Aug  8 14:02 so.o

If you are getting an error please be sure to post the actual code, the command used to compile or interpret, the version of the compiler, and the error message itself.