Add Type To Element Of Data Structure In Haskell

[Solved] Add Type To Element Of Data Structure In Haskell | Haskell - Code Explorer | yomemimo.com
Question : add type to element of data structure in haskell

Answered by : inexpensive-ibis-85ins0n76pcx

data FightMove = Punch Int | Kick Int Float | Block String
chooseMove :: Int -> FightMove
chooseMove i = if i == 1 then Punch 3 Else if i == 2 then Kick 3 6.5 else Block “Please Protect Me”

Source : https://mmhaskell.com/blog/2016/12/17/making-your-own-data-types-in-haskell | Last Update : Fri, 14 Jan 22

Answers related to add type to element of data structure in haskell

Code Explorer Popular Question For Haskell