data Status = Not done | Done | Made by data of the month = January | February | Martha | April | May | June | July | Augusta | September | October | November | December data Date = Date Integer Month Integer data When = WhenBy | From Date | By date | Between Date Date | Age Integer data to = Work | Home | To customer | On the resort | In the shop data Whom = Son | Daughter | Children Integer data Nakom = Unknown | Vera | Katya | Masha data What = Tree | House | Liver | Company | Factory | School | Kindergarten | University | Treasure data Which Document = Contract | Will | Contract | Diploma data Holiday = New Year | Birthday data WhatMake = To be born | Die | Marry Nick | To give birth to Whom | Plant what | Build What | Finish what | Find What | Arrange What | Buy What | Sell What | Sign What Document | Earn Integer | Celebrate the Holiday | Go where | Go where | Fly off | Go where data Project = Project String [Project] | Action WhatMake When Status life :: Project life = Project "Life" [ Action To be born (Age 0) Made, Project "Education" [ Action (Graduate School) (Age 16) Done, Action (Graduate University) (Age 20) Done ], Project "Family" [ Action (Marry Unknown) WhenNibbe Done, Action (To give birth to a Son) When There Is Not Done, Action (Give birth to Daughter) When There Is No Made, Action (Give birth (Children 1)) WhenNothing is Done ], Project "Work" [ Action (Sign a Contract) When There Is No Made, Action (Earn $ foldr (*) 1 [1..20]) WhenNib Be Done ], Project "Rest" [ Action (Celebrate New Year) (Between (Date December 31, 2009) (Date January 4, 2010)) Done ], Action To Die When Never Made ] Universe :: Project universe = "Everything Else" project (repeat universe) - the project is completed when all its actions are completed completed :: Project -> Bool completed (Action _ _ Done) = True completed (Project _ list) = all list completed completed _ = False - nbgf ghbrjk Answer :: Project -> Integer answer _ = 42
GHCi, version 6.8.2: http://www.haskell.org/ghc/:? for help Loading package base ... linking ... done. Prelude>: l now / gtd / gtd.hs [1 of 1] Compiling Main (now / gtd / gtd.hs, interpreted) Ok, modules loaded: Main. * Main> answer is life 42 * Main> Universe Answer 42 * Main> completed life False * Main> Completed Universe *** Exception: stack overflow * Main>
Source: https://habr.com/ru/post/57873/
All Articles