1

I did some research about Colored Petri Nets for a university assessment, and I need to implement them in Haskell. I used this document as a point of start.

When I am trying to import this module in Haskell:

module SimpleHCPN where

import Data.List
import System.Random

data Net marking = Net {trans :: [Transition marking]}
                   deriving (Show)
data Transition marking = Transition { name :: String
                                     , action :: marking -> [marking]
                                     }
                          deriving (Show)

I receive the following error:

SimpleHCPN.hs:11:37: error:
    * No instance for (Show (marking -> [marking]))
        arising from the second field of `Transition'
          (type `marking -> [marking]')
        (maybe you haven't applied a function to enough arguments?)
      Possible fix:
        use a standalone 'deriving instance' declaration,
          so you can specify the instance context yourself
    * When deriving the instance for (Show (Transition marking))

I'm still a newbie in Haskell, so a little bit of help would be appreciated.

Thanks, Denis

  • More related questions: [1](https://stackoverflow.com/q/15823732/791604), [2](https://stackoverflow.com/q/15015698/791604), [3](https://stackoverflow.com/q/10551210/791604). – Daniel Wagner Jun 14 '17 at 21:15

1 Answers1

3

action is of type marking -> [marking] and there is no instance of typeclass Show for functions.

You can import Text.Show.Functions for an typeclass instance of Show for functions, but I don't know, if it shows something useful or only "Function" for any function.

typetetris
  • 4,586
  • 16
  • 31
  • If the domain is small, [Data.Universe.Instances.Show](http://hackage.haskell.org/package/universe-reverse-instances-1.0/docs/src/Data-Universe-Instances-Show.html) is another alternative. – Daniel Wagner Jun 14 '17 at 21:16