{-# LANGUAGE TemplateHaskell #-}


module Potato.Flow.TutorialState (tutorialState) where

import           Relude

import           Potato.Flow

import           Data.ByteString
import qualified Data.ByteString.Lazy as LBS
import           Data.FileEmbed  (embedFile)

import qualified Data.Text as T
import qualified Data.Aeson as Aeson
import           Potato.Flow.TestStates

tutorialState :: (OwlPFState, ControllerMeta)
tutorialState :: (OwlPFState, ControllerMeta)
tutorialState = forall a. a -> Maybe a -> a
fromMaybe (OwlPFState
owlpfstate_newProject, ControllerMeta
emptyControllerMeta)  forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(SPotatoFlow
x, ControllerMeta
cm) -> (SPotatoFlow -> OwlPFState
sPotatoFlow_to_owlPFState SPotatoFlow
x, ControllerMeta
cm)) forall a b. (a -> b) -> a -> b
$ case forall a. FromJSON a => ByteString -> Either String a
Aeson.eitherDecode (ByteString -> ByteString
LBS.fromStrict ByteString
tutorialjson) of
  --Left e -> error (T.pack e) -- Nothing
  Left String
e -> forall a. Maybe a
Nothing
  Right (SPotatoFlow, ControllerMeta)
j -> forall a. a -> Maybe a
Just (SPotatoFlow, ControllerMeta)
j

tutorialjson :: ByteString
tutorialjson :: ByteString
tutorialjson = $(embedFile "tutorial.potato")