[SOLVED] CS代考程序代写 Haskell {-

30 $

File Name: CS代考程序代写_Haskell_{-.zip
File Size: 292.02 KB

SKU: 7952409206 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


{-
Module: StateTreeInstances.

Used by quickcheck in the tests.
-}
module Util.StateTreeInstances where

import Test.QuickCheck
import Control.Monad

import Types

— Generate an arbitrary state tree.
arbitraryTree :: (Arbitrary v, Arbitrary a) => Int -> Gen (StateTree v a)
arbitraryTree 0 = do
x <- arbitrary return (StateTree x [])arbitraryTree n = do m <- arbitrary let n’ = n `div` (m + 1)x <- arbitraryas <- replicateM m arbitraryts <- replicateM m (arbitraryTree n’)return (StateTree x (zip as ts))– Tell Haskell that we can generate arbitrary state trees.instance (Arbitrary v, Arbitrary a) => Arbitrary (StateTree v a) where
arbitrary = sized arbitraryTree

— Describes how state trees are printed.
instance (Show v, Show a) => Show (StateTree v a) where
show (StateTree v ts) = “(StateTree ” ++ (show v) ++ ” ” ++ (show ts) ++ “)”

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS代考程序代写 Haskell {-
30 $